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.

1361 lines
49 KiB

  1. /* _EDIT.H
  2. *
  3. * Purpose:
  4. * Base classes for rich-text manipulation
  5. *
  6. * Authors:
  7. * Christian Fortini
  8. * Murray Sargent (and many others)
  9. *
  10. * Copyright (c) 1995-2000, Microsoft Corporation. All rights reserved.
  11. */
  12. #ifndef _EDIT_H
  13. #define _EDIT_H
  14. #include "textserv.h"
  15. #include "textsrv2.h"
  16. #include "_ldte.h"
  17. #include "_m_undo.h"
  18. #include "_notmgr.h"
  19. #include "_doc.h"
  20. #include "_objmgr.h"
  21. #include "_cfpf.h"
  22. #include "_callmgr.h"
  23. #include "_magelln.h"
  24. #ifndef NOPRIVATEMESSAGE
  25. #include "_MSREMSG.H"
  26. #include "_textnot.h"
  27. #endif
  28. #ifndef NOINKOBJECT
  29. #include "HWXInk.h"
  30. #endif
  31. // Forward declarations
  32. class CRchTxtPtr;
  33. class CTxtSelection;
  34. class CTxtStory;
  35. class CTxtUndo;
  36. class CMeasurer;
  37. class CRenderer;
  38. class CDisplay;
  39. class CDisplayPrinter;
  40. class CDrawInfo;
  41. class CDetectURL;
  42. class CUniscribe;
  43. class CTxtBreaker;
  44. class CHyphCache;
  45. // Macro for finding parent "this" of embedded class. If this turns out to be
  46. // globally useful we should move it to _common.h.
  47. #define GETPPARENT(pmemb, struc, membname) (\
  48. (struc FAR *)(((char FAR *)(pmemb))-offsetof(struc, membname)))
  49. // These wonderful constants are for backward compatibility. They are the
  50. // sizes used for initialization and reset in RichEdit 1.0
  51. const LONG cInitTextMax = (32 * 1024) - 1;
  52. const LONG cResetTextMax = (64 * 1024);
  53. extern DWORD CALLBACK ReadHGlobal (DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb);
  54. extern DWORD GetKbdFlags(WORD vkey, DWORD dwFlags);
  55. extern BYTE szUTF8BOM[];
  56. extern WORD g_wFlags; // Toggled by Ctrl-"
  57. #define KF_SMARTQUOTES 0x0001 // Enable smart quotes
  58. #define SmartQuotesEnabled() (g_wFlags & KF_SMARTQUOTES)
  59. struct SPrintControl
  60. {
  61. union
  62. {
  63. DWORD _dwAllFlags; // Make it easy to set all flags at once.
  64. struct
  65. {
  66. ULONG _fDoPrint:1; // Whether actual print is required
  67. ULONG _fPrintFromDraw:1; // Whether draw is being used to print
  68. };
  69. };
  70. SPrintControl(void) { _dwAllFlags = 0; }
  71. };
  72. enum DOCUMENTTYPE
  73. {
  74. DT_LTRDOC = 1, // DT_LTRDOC and DT_RTLDOC are mutually
  75. DT_RTLDOC = 2, // exclusive
  76. };
  77. // Context rule settings.
  78. // Optimally, these would be an enum, but we run into sign extension glitchs
  79. // sticking an enum into a 2-bit field.
  80. #define CTX_NONE 0 // No context direction/alignment.
  81. #define CTX_NEUTRAL 1 // No strong characters in the control, direction/alignment follows keyboard.
  82. #define CTX_LTR 2 // LTR direction/alignment (first strong character is LTR)
  83. #define CTX_RTL 3 // RTL direction/alignment (first strong character is RTL)
  84. #define IsStrongContext(x) (x >= CTX_LTR)
  85. class CDocInfo // Contains ITextDocument info
  86. {
  87. public:
  88. BSTR _pName; // Document filename
  89. HANDLE _hFile; // Handle used unless full file sharing
  90. WORD _wFlags; // Open, share, create, and save flags
  91. WORD _wCpg; // Code page
  92. LONG _dwDefaultTabStop; // TOM settable default tab stop
  93. LCID _lcid; // Document lcid (for RTF \deflang)
  94. LCID _lcidfe; // Document FE lcid (for RTF \deflangfe)
  95. LPSTR _lpstrLeadingPunct; // Leading kinsoku characters
  96. LPSTR _lpstrFollowingPunct; // Following kinsoku characters
  97. COLORREF *_prgColor; // Special color array
  98. COLORREF _crColor; // Background color
  99. COLORREF _crBackColor; // Background color
  100. HGLOBAL _hdata; // Background data
  101. HBITMAP _hBitmapBack; // Background bitmap
  102. char _cColor; // Allocated count of colors in pColor
  103. BYTE _bDocType; // 0-1-2: export none-\ltrdoc-\rtldoc
  104. // If 0x80 or'd in, PWD instead of RTF
  105. BYTE _bCaretType; // Caret type
  106. char _nFillType; // Background fill type
  107. SHORT _sFillAngle; // Fill angle
  108. BYTE _bFillFocus; // Background fill focus
  109. BYTE _bPicFormat; // Background Picture format
  110. BYTE _bPicFormatParm; // Background Picture format parameter
  111. RECT _rcCrop; // Background cropping RECT
  112. SHORT _xExt, _yExt; // Dimensions in pixels for pictures, twips for
  113. // for objects
  114. SHORT _xScale, _yScale; // Scaling percentage along axes
  115. SHORT _xExtGoal, _yExtGoal; // Desired dimensions in twips for pictures
  116. SHORT _xExtPict, _yExtPict; // Metafile dimensions
  117. AutoCorrectProc _pfnAutoCorrect;
  118. CDocInfo() {Init();} // Constructor
  119. ~CDocInfo(); // Destructor
  120. void Init();
  121. void InitBackground();
  122. };
  123. const DWORD tomInvalidCpg = 0xFFFF;
  124. const DWORD tomInvalidLCID = 0xFFFE;
  125. // This depends on the number of property bits defined in textserv.h. However,
  126. // this is for private use by the text services so it is defined here.
  127. #define MAX_PROPERTY_BITS 21
  128. #define SPF_SETDEFAULT 4
  129. // IDispatch global declarations
  130. extern ITypeInfo * g_pTypeInfoDoc;
  131. extern ITypeInfo * g_pTypeInfoSel;
  132. extern ITypeInfo * g_pTypeInfoFont;
  133. extern ITypeInfo * g_pTypeInfoPara;
  134. HRESULT GetTypeInfoPtrs();
  135. HRESULT GetTypeInfo(UINT iTypeInfo, ITypeInfo *&pTypeInfo,
  136. ITypeInfo **ppTypeInfo);
  137. BOOL IsSameVtables(IUnknown *punk1, IUnknown *punk2);
  138. // Map from keyboard to font. (converse is handled in font.cpp)
  139. typedef struct _kbdFont
  140. {
  141. WORD iKbd;
  142. SHORT iCF;
  143. } KBDFONT;
  144. LONG CheckTwips(LONG x);
  145. QWORD GetCharFlags(const WCHAR *pch, LONG cchPch = 1, BYTE iCharRepDefault = 0);
  146. LONG TwipsToHalfPoints(LONG x);
  147. LONG TwipsToQuarterPoints(LONG x);
  148. // Convert between Twips and Himetric
  149. // Ratio is 1440 twips/in, 2540 him/in, therefore 1440/2540 = 72/127 him/twips
  150. // Use muldiv() to include rounding and 64-bit intermediate result
  151. #define TwipsFromHimetric(hm) MulDiv(hm, 72, 127)
  152. #define HimetricFromTwips(tw) MulDiv(tw, 127, 72)
  153. CUniscribe* GetUniscribe(void);
  154. #define FRTL 0x00000001
  155. #define FDIGITSHAPE 0x00000002
  156. #define FCOMBINING 0x00000008
  157. #define FSURROGATE 0x00000010
  158. #define FUNIC_CTRL 0x00000020
  159. #define FBELOWX40 0x00000040 // ASCII 0x00-0x3F
  160. #define FASCIIUPR 0x00000080 // ASCII 0x40-0x7F
  161. /* The font signature fsCsb[0] has the bit definitions
  162. 0 1252 Latin 1
  163. 1 1250 Latin 2: Eastern Europe
  164. 2 1251 Cyrillic
  165. 3 1253 Greek
  166. 4 1254 Turkish
  167. 5 1255 Hebrew
  168. 6 1256 Arabic
  169. 7 1257 Baltic
  170. 8 1258 Vietnamese
  171. 9 - 15 Reserved for ANSI
  172. 16 874 Thai
  173. 17 932 JIS/Japan
  174. 18 936 Chinese: Simplified chars--PRC, Hong Kong SAR, Singapore
  175. 19 949 Korean Unified Hangul Code (Hangul TongHabHyung Code)
  176. 20 950 Chinese: Traditional chars--Taiwan
  177. We define bit masks which are similar to the values above shifted over
  178. one byte (add 8) to make room for a low byte of special flags like FRTL
  179. in _qwCharFlags. In addition, we define some Unicode-only repertoires
  180. using info in the Unicode subset fields fsUsb[].
  181. This approach uses a 64-bit _qwCharFlags and currently can add 6 more
  182. character repertoires (actually writing systems). If more are needed, an
  183. approach with an array of three (or more as needed) DWORDs could be used
  184. as in the Win32 FONTSIGNATURE.
  185. */
  186. #define FHILATIN1 0x00000100
  187. #define FLATIN2 0x00000200
  188. #define FCYRILLIC 0x00000400
  189. #define FGREEK 0x00000800
  190. #define FTURKISH 0x00001000
  191. #define FHEBREW 0x00002000
  192. #define FARABIC 0x00004000
  193. #define FBALTIC 0x00008000
  194. #define FVIETNAMESE 0x00010000
  195. #define FOTHER 0x00020000
  196. #define FSYMBOL 0x00040000
  197. #define FTHAI 0x00080000
  198. #define FKANA 0x00100000
  199. #define FCHINESE 0x00200000 // Simplified Chinese
  200. #define FHANGUL 0x00400000
  201. #define FBIG5 0x00800000 // Traditional Chinese
  202. #define FMATHGENR 0x01000000 // Generic math
  203. #define FMATHITAL 0x02000000 // Math alphanumerics
  204. #define FMATHBOLD 0x04000000
  205. #define FMATHSCRP 0x08000000
  206. #define FMATHFRAK 0x10000000
  207. #define FMATHOPEN 0x20000000
  208. #define FMATHSANS 0x40000000
  209. #define FMATHMONO 0x80000000
  210. // Unicode-only character repertoires. If you add new repertoire flags, add
  211. // corresponding xxx_INDEX values in _w32sys.h and change CW32System::
  212. // CharRepFontSig() and CW32System::FontSigFromCharRep().
  213. #define FARMENIAN 0x0000000100000000 // 0x0530 - 0x058F
  214. #define FSYRIAC 0x0000000200000000 // 0x0700 - 0x074F
  215. #define FTHAANA 0x0000000400000000 // 0x0780 - 0x07BF
  216. #define FDEVANAGARI 0x0000000800000000 // 0x0900 - 0x097F
  217. #define FBENGALI 0x0000001000000000 // 0x0980 - 0x09FF
  218. #define FGURMUKHI 0x0000002000000000 // 0x0A00 - 0x0A7F
  219. #define FGUJARATI 0x0000004000000000 // 0x0A80 - 0x0AFF
  220. #define FORYIA 0x0000008000000000 // 0x0B00 - 0x0B7F
  221. #define FTAMIL 0x0000010000000000 // 0x0B80 - 0x0BFF
  222. #define FTELEGU 0x0000020000000000 // 0x0C00 - 0x0C7F
  223. #define FKANNADA 0x0000040000000000 // 0x0C80 - 0x0CFF
  224. #define FMALAYALAM 0x0000080000000000 // 0x0D00 - 0x0D7F
  225. #define FSINHALA 0x0000100000000000 // 0x0D80 - 0x0DFF
  226. #define FLAO 0x0000200000000000 // 0x0E80 - 0x0EFF
  227. #define FTIBETAN 0x0000400000000000 // 0x0F00 - 0x0FBF
  228. #define FMYANMAR 0x0000800000000000 // 0x1000 - 0x109F
  229. #define FGEORGIAN 0x0001000000000000 // 0x10A0 - 0x10FF
  230. #define FJAMO 0x0002000000000000 // 0x1100 - 0x11FF
  231. #define FETHIOPIC 0x0004000000000000 // 0x1200 - 0x137F
  232. #define FCHEROKEE 0x0008000000000000 // 0x13A0 - 0x13FF
  233. #define FABORIGINAL 0x0010000000000000 // 0x1400 - 0x167F
  234. #define FOGHAM 0x0020000000000000 // 0x1680 - 0x169F
  235. #define FRUNIC 0x0040000000000000 // 0x16A0 - 0x16F0
  236. #define FKHMER 0x0080000000000000 // 0x1780 - 0x17FF
  237. #define FMONGOLIAN 0x0100000000000000 // 0x1800 - 0x18AF
  238. #define FBRAILLE 0x0200000000000000 // 0x2800 - 0x28FF
  239. #define FYI 0x0400000000000000 // 0xA000 - 0xA4CF
  240. // Keep next 4 in same order as FKANA - FBIG5
  241. #define FJPN2 0x0800000000000000 // 0x20000 - 2FFFFF Japanese
  242. #define FCHS2 0x1000000000000000 // 0x20000 - 2FFFFF Simplified Chinese
  243. #define FKOR2 0x2000000000000000 // 0x20000 - 2FFFFF Korean
  244. #define FCHT2 0x4000000000000000 // 0x20000 - 2FFFFF Traditional Chinese
  245. #define FASCII (FASCIIUPR | FBELOWX40)
  246. #define FLATIN1 (FASCII | FHILATIN1)
  247. #define FLATIN (FHILATIN1 | FLATIN2 | FTURKISH | FBALTIC | FVIETNAMESE)
  248. #define FBIDI (FRTL | FARABIC | FHEBREW | FSYRIAC | FTHAANA | FDIGITSHAPE)
  249. #define FFE (FKANA | FCHINESE | FBIG5 | FHANGUL)
  250. #define FFE2 (FJPN2 | FCHS2 | FCHT2 | FKOR2)
  251. #define FMATH (FMATHGENR | FMATHITAL | FMATHBOLD | FMATHSCRP | FMATHFRAK | \
  252. FMATHOPEN | FMATHSANS | FMATHMONO)
  253. #define FINDIC (FDEVANAGARI | FBENGALI | FGURMUKHI | FGUJARATI | FORYIA | \
  254. FTAMIL | FTELEGU | FKANNADA | FMALAYALAM | FSINHALA)
  255. #define FABOVEX7FF (FTHAI | FFE | FOTHER | FINDIC | FLAO | FTIBETAN | FMYANMAR | \
  256. FGEORGIAN | FJAMO | FETHIOPIC | FCHEROKEE | FABORIGINAL | \
  257. FOGHAM | FRUNIC | FKHMER | FMONGOLIAN | FBRAILLE | FYI)
  258. #define FNEEDWORDBREAK FTHAI
  259. #define FNEEDCHARBREAK (FTHAI | FINDIC)
  260. #define FCOMPLEX_SCRIPT (FBIDI | FTHAI | FINDIC | FJAMO | FCOMBINING | FSURROGATE)
  261. #define RB_DEFAULT 0x00000000 // Perform default behavior
  262. #define RB_NOSELCHECK 0x00000001 // For OnTxRButtonUp, bypass pt in selection check
  263. #define RB_FORCEINSEL 0x00000002 // Force point into selection (used by keyboard
  264. // to get context menus)
  265. // Flags for OnTxLButtonUp
  266. #define LB_RELEASECAPTURE 0x00000001 // Force release mouse capture
  267. #define LB_FLUSHNOTIFY 0x00000002 // 1.0 mode force selection change notification
  268. // if selChange is cached
  269. enum AccentIndices
  270. {
  271. ACCENT_GRAVE = 1,
  272. ACCENT_ACUTE,
  273. ACCENT_CARET,
  274. ACCENT_TILDE,
  275. ACCENT_UMLAUT,
  276. ACCENT_CEDILLA
  277. };
  278. #define KBD_CHAR 2 // Must be a bit value > 1
  279. #define KBD_CTRL 4 // Must be a bit value > 2
  280. #define KBD_NOAUTOCORRECT 8 // Must be a bit value > 4
  281. // ================================== CTxtEdit ============================================
  282. // Outer most class for a Text Control.
  283. class CTxtEdit : public ITextServices, public IRichEditOle, public ITextDocument2
  284. {
  285. public:
  286. friend class CCallMgr;
  287. friend class CMagellanBMPStateWrap;
  288. CTxtEdit(ITextHost2 *phost, IUnknown *punkOuter);
  289. ~CTxtEdit ();
  290. // Initialization
  291. BOOL Init(const RECT *prcClient);
  292. // A helper function
  293. LONG GetTextLength() const {return _story.GetTextLength();}
  294. LONG GetAdjustedTextLength();
  295. // Access to ActiveObject members
  296. IUnknown * GetPrivateIUnknown() { return &_unk; }
  297. CLightDTEngine *GetDTE() { return &_ldte; }
  298. IUndoMgr * GetUndoMgr() { return _pundo; }
  299. IUndoMgr * GetRedoMgr() { return _predo; }
  300. IUndoMgr * CreateUndoMgr(LONG cUndoLim, USFlags flags);
  301. CCallMgr * GetCallMgr()
  302. {Assert(_pcallmgr); return _pcallmgr;}
  303. static CHyphCache * GetHyphCache(void);
  304. CObjectMgr * GetObjectMgr();
  305. // the callback is provided by the client
  306. // to help with OLE support
  307. BOOL HasObjects() {return _pobjmgr && _pobjmgr->GetObjectCount();}
  308. IRichEditOleCallback *GetRECallback()
  309. { return _pobjmgr ? _pobjmgr->GetRECallback() : NULL; }
  310. LRESULT HandleSetUndoLimit(LONG Count);
  311. LRESULT HandleSetTextMode(DWORD mode);
  312. LRESULT HandleSetTextFlow(DWORD mode);
  313. CCcs* GetCcs(const CCharFormat *const pCF, const LONG dvpInch, DWORD dwFlags = -1, HDC hdc = 0);
  314. CNotifyMgr * GetNotifyMgr();
  315. CDetectURL * GetDetectURL() {return _pdetecturl;}
  316. CUniscribe * Getusp() const {return GetUniscribe();}
  317. #ifndef NOMAGELLAN
  318. CMagellan mouse;
  319. LRESULT HandleMouseWheel(WPARAM wparam, LPARAM lparam);
  320. #endif
  321. void AutoCorrect(CTxtSelection *psel, WCHAR ch, IUndoBuilder *publdr);
  322. // Misc helpers
  323. LONG GetAcpFromCp(LONG cp, BOOL fPrecise=0);
  324. LONG GetCpFromAcp(LONG acp, BOOL fPrecise=0);
  325. #ifndef NOANSIWINDOWS
  326. BOOL Get10Mode() const {return _f10Mode;}
  327. BOOL fUseCRLF() const {return _f10Mode;}
  328. BOOL fCpMap() const {return _f10Mode;}
  329. #else
  330. BOOL Get10Mode() const {return FALSE;}
  331. BOOL fUseCRLF() const {return FALSE;}
  332. BOOL fCpMap() const {return FALSE;}
  333. #endif
  334. LONG GetCpAccelerator() const {return _cpAccelerator;}
  335. short GetFreezeCount() const {return _cFreeze;}
  336. #ifndef NOWINDOWHOSTS
  337. BOOL fInOurHost() const {return _fInOurHost;}
  338. #else
  339. BOOL fInOurHost() const {return FALSE;}
  340. #endif
  341. BOOL fInHost2() const {return _fHost2;}
  342. BOOL fInplaceActive() const {return _fInPlaceActive;}
  343. BOOL fHideGridlines() const {return _fHideGridlines;}
  344. BOOL fHideSelection() const {return _fHideSelection;}
  345. BOOL fXltCRCRLFtoCR() const {return _fXltCRCRLFtoCR;}
  346. BOOL fUsePassword() const {return _fUsePassword;}
  347. BOOL FUseCustomTextOut() const {return !(_bTypography & TO_DISABLECUSTOMTEXTOUT);}
  348. BOOL fUseLineServices() const {return _bTypography & TO_ADVANCEDTYPOGRAPHY;}
  349. BOOL fUseSimpleLineBreak() const {return (_bTypography & TO_SIMPLELINEBREAK) != 0;}
  350. BOOL fUseObjectWrapping() const {return (_bTypography & TO_ADVANCEDLAYOUT) != 0;}
  351. #ifndef NOAUTOFONT
  352. BOOL IsAutoFont() const {return _fAutoFont;};
  353. BOOL IsAutoKeyboard() const {return _fAutoKeyboard;};
  354. BOOL IsAutoFontSizeAdjust() const{return _fAutoFontSizeAdjust;};
  355. #else
  356. BOOL IsAutoFont() const {return FALSE;};
  357. BOOL IsAutoKeyboard() const {return FALSE;};
  358. BOOL IsAutoFontSizeAdjust() const{return FALSE;};
  359. #endif
  360. BOOL IsBiDi() const {return (_qwCharFlags & FBIDI) != 0;}
  361. BOOL IsComplexScript() const {return (_qwCharFlags & FCOMPLEX_SCRIPT) != 0;}
  362. #ifndef NOFEPROCESSING
  363. BOOL IsFE() const {return (_qwCharFlags & FFE) != 0;}
  364. #else
  365. BOOL IsFE() const {return FALSE;}
  366. #endif
  367. BOOL IsInOutlineView() const {return _fOutlineView;}
  368. BOOL IsInPageView() const {return _fPageView;}
  369. BOOL IsMouseDown() const {return _fMouseDown;}
  370. #ifndef NOPLAINTEXT
  371. BOOL IsRich() const {return _fRich;}
  372. #else
  373. BOOL IsRich() const {return TRUE;}
  374. #endif
  375. BOOL IsLeftScrollbar() const;
  376. BOOL IsSelectionBarRight() const {return IsLeftScrollbar(); }
  377. void SetfSelChangeCharFormat() {_fSelChangeCharFormat = TRUE; }
  378. BOOL DelayChangeNotification() {return _f10DeferChangeNotify;}
  379. BOOL GetOOMNotified() {return _fOOMNotified;}
  380. void SetOOMNotified(BOOL ff)
  381. {
  382. Assert(ff == 1 || ff == 0);
  383. _fOOMNotified = ff;
  384. }
  385. //plain-text controls always use the UIFont
  386. bool fUseUIFont() const {return !_fRich || _fUIFont;}
  387. BOOL IsTransparent() {return _fTransparent;}
  388. LONG GetZoomNumerator() const {return _wZoomNumerator;}
  389. LONG GetZoomDenominator() const {return _wZoomDenominator;}
  390. void SetZoomNumerator(LONG x) {_wZoomNumerator = (WORD)x;}
  391. void SetZoomDenominator(LONG x) {_wZoomDenominator = (WORD)x;}
  392. LONG GetCpFirstStrong() {return _cpFirstStrong;}
  393. void SetReleaseHost();
  394. QWORD GetCharFlags() const {return _qwCharFlags;}
  395. BOOL IsDocMoreThanLatin1Symbol() {return (GetCharFlags() & ~(FLATIN1 | FSYMBOL)) != 0;}
  396. void OrCharFlags(QWORD qwFlags, IUndoBuilder* publdr = NULL);
  397. void Beep();
  398. void HandleKbdContextMenu();
  399. void Set10Mode();
  400. void SetContextDirection(BOOL fUseKbd = FALSE);
  401. void ItemizeDoc(IUndoBuilder* publdr = NULL, LONG cchRange = -1);
  402. HRESULT UpdateAccelerator();
  403. HRESULT UpdateOutline();
  404. HRESULT MoveSelection(LPARAM lparam, IUndoBuilder *publdr);
  405. HRESULT PopAndExecuteAntiEvent(IUndoMgr *pundomgr, void *pAE);
  406. BOOL InsertEOP(DWORD dwFlags, BOOL fShift, IUndoBuilder* publdr);
  407. HRESULT CutOrCopySelection(UINT msg, WPARAM wparam, LPARAM lparam,
  408. IUndoBuilder *publdr);
  409. HRESULT PasteDataObjectToRange(
  410. IDataObject *pdo,
  411. CTxtRange *prg,
  412. CLIPFORMAT cf,
  413. REPASTESPECIAL *rps,
  414. IUndoBuilder *publdr,
  415. DWORD dwFlags );
  416. // Story access
  417. CTxtStory * GetTxtStory () {return &_story;}
  418. // Get access to cached CCharFormat and CParaFormat structures
  419. const CCharFormat* GetCharFormat(LONG iCF)
  420. {return _story.GetCharFormat(iCF);}
  421. const CParaFormat* GetParaFormat(LONG iPF)
  422. {return _story.GetParaFormat(iPF);}
  423. LONG Get_iCF() {return _story.Get_iCF();}
  424. LONG Get_iPF() {return _story.Get_iPF();}
  425. void Set_iCF(LONG iCF) {_story.Set_iCF(iCF);}
  426. void Set_iPF(LONG iPF) {_story.Set_iPF(iPF);}
  427. HRESULT HandleStyle(CCharFormat *pCFTarget, const CCharFormat *pCF,
  428. DWORD dwMask, DWORD dwMask2);
  429. HRESULT HandleStyle(CParaFormat *pPFTarget, const CParaFormat *pPF,
  430. DWORD dwMask, DWORD dwMask2);
  431. // Get host interface pointer
  432. ITextHost2 *GetHost() {return _phost;}
  433. // Helper for getting CDocInfo ptr and creating it if NULL
  434. CDocInfo * GetDocInfo();
  435. CDocInfo * GetDocInfoNC() {return _pDocInfo;}
  436. HRESULT InitDocInfo();
  437. LONG GetBackgroundType();
  438. LONG GetDefaultTab()
  439. {return _pDocInfo ? _pDocInfo->_dwDefaultTabStop : lDefaultTab;};
  440. HRESULT SetDefaultLCID (LCID lcid);
  441. HRESULT GetDefaultLCID (LCID *pLCID);
  442. HRESULT SetDefaultLCIDFE (LCID lcid);
  443. HRESULT GetDefaultLCIDFE (LCID *pLCID);
  444. HRESULT SetDocumentType (LONG DocType);
  445. HRESULT GetDocumentType (LONG *pDocType);
  446. HRESULT GetFollowingPunct(LPSTR *plpstrFollowingPunct);
  447. HRESULT SetFollowingPunct(LPSTR lpstrFollowingPunct);
  448. HRESULT GetLeadingPunct (LPSTR *plpstrLeadingPunct);
  449. HRESULT SetLeadingPunct (LPSTR lpstrLeadingPunct);
  450. HRESULT GetViewKind (LRESULT *plres);
  451. HRESULT SetViewKind (long Value);
  452. HRESULT GetViewScale (long *pValue);
  453. HRESULT SetViewScale (long Value);
  454. // Notification Management Methods. In principle, these methods
  455. // could form a separate class, but for space savings, they are part
  456. // of the CTxtEdit class
  457. HRESULT TxNotify(DWORD iNotify, void *pv); //@cmember General-purpose
  458. // notification
  459. void SendScrollEvent(DWORD iNotify); //@cmember Send scroll
  460. // event
  461. void SendUpdateEvent(); //@cmember Send EN_UPDATE
  462. // event
  463. //@cmember Use EN_PROTECTED
  464. BOOL QueryUseProtection( CTxtRange *prg, // to query protection
  465. UINT msg,WPARAM wparam, LPARAM lparam);// usage
  466. //@cmember Indicates whether
  467. // protection checking enabled
  468. BOOL IsProtectionCheckingEnabled()
  469. {return !!(_dwEventMask & ENM_PROTECTED);}
  470. // FUTURE (alexgo): maybe we can use just one method :-)
  471. BOOL IsntProtectedOrReadOnly(UINT msg, WPARAM wparam, LPARAM lparam, BOOL fBeep = TRUE);
  472. BOOL IsProtected(UINT msg, WPARAM wparam, LPARAM lparam);
  473. BOOL IsProtectedRange(UINT msg, WPARAM wparam, LPARAM lparam, CTxtRange *prg);
  474. void SetStreaming(BOOL flag) {_fStreaming = flag;}
  475. BOOL IsStreaming() {return _fStreaming;}
  476. DWORD GetEventMask(){return _dwEventMask;}//@cmember Get event mask
  477. //@cmember Handles EN_LINK
  478. BOOL HandleLinkNotification(UINT msg, WPARAM wparam, LPARAM lparam,
  479. BOOL *pfInLink = NULL);
  480. BOOL HandleLowFiRTF(char *szControl); //@cmember Handles EN_LOWFIRTF
  481. HRESULT CloseFile (BOOL bSave);
  482. // Helper for determine when to load message filter
  483. BOOL LoadMsgFilter (UINT msg, WPARAM wparam, LPARAM lparam);
  484. #ifndef NOINKOBJECT
  485. // Helper function to setup ink object properties
  486. HRESULT SetInkProps( LONG cp, ILineInfo *pILineInfo, UINT *piInkWidth );
  487. #endif
  488. LONG GetCaretWidth();
  489. //--------------------------------------------------------------
  490. // Inline proxies to ITextHost methods
  491. //--------------------------------------------------------------
  492. // Persisted properties (persisted by the host)
  493. // Get methods: called by the Text Services component to get
  494. // the value of a given persisted property
  495. // FUTURE (alexgo) !! some of these need to get cleaned up
  496. BOOL TxGetAutoSize() const;
  497. BOOL TxGetAutoWordSel() const;
  498. COLORREF TxGetBackColor() const;
  499. TXTBACKSTYLE TxGetBackStyle() const;
  500. HRESULT TxGetDefaultCharFormat(CCharFormat *pCF, DWORD &dwMask);
  501. void TxGetClientRect(RECTUV *prc) const;
  502. void TxGetClientRect(LPRECT prc) const {_phost->TxGetClientRect(prc);}
  503. HRESULT TxGetExtent(SIZEL *psizelExtents)
  504. {return _phost->TxGetExtent(psizelExtents);}
  505. COLORREF TxGetForeColor() const {return _phost->TxGetSysColor(COLOR_WINDOWTEXT);}
  506. DWORD TxGetMaxLength() const;
  507. void TxSetMaxToMaxText(LONG cExtra = 0);
  508. BOOL TxGetModified() const {return _fModified;}
  509. HRESULT TxGetDefaultParaFormat(CParaFormat *pPF);
  510. TCHAR TxGetPasswordChar() const;
  511. BOOL TxGetReadOnly() const {return _fReadOnly;}
  512. BOOL TxGetSaveSelection() const;
  513. DWORD TxGetScrollBars() const ;
  514. LONG TxGetSelectionBarWidth() const;
  515. void TxGetViewInset(RECTUV *prc, CDisplay const *pdp) const;
  516. BOOL TxGetWordWrap() const;
  517. BOOL TxClientToScreen (LPPOINT lppt) {return _phost->TxClientToScreen(lppt); }
  518. BOOL TxScreenToClient (LPPOINT lppt) {return _phost->TxScreenToClient(lppt); }
  519. // ITextHost 2 wrappers
  520. BOOL TxIsDoubleClickPending();
  521. HRESULT TxGetWindow(HWND *phwnd);
  522. HRESULT TxSetForegroundWindow();
  523. HPALETTE TxGetPalette();
  524. HRESULT TxGetFEFlags(LONG *pFEFlags);
  525. HCURSOR TxSetCursor(HCURSOR hcur, BOOL fText = FALSE);
  526. // Allowed only when in in-place
  527. // The host will fail if not in-place
  528. HDC TxGetDC() {return _phost->TxGetDC();}
  529. INT TxReleaseDC(HDC hdc) {return _phost->TxReleaseDC(hdc);}
  530. // Helper functions for metafile support
  531. INT TxReleaseMeasureDC( HDC hMeasureDC );
  532. void TxUpdateWindow()
  533. {
  534. _phost->TxViewChange(_fInPlaceActive ? TRUE : FALSE);
  535. }
  536. void TxScrollWindowEx (INT dx, INT dy, LPCRECT lprcScroll, LPCRECT lprcClip);
  537. void TxSetCapture(BOOL fCapture)
  538. {_phost->TxSetCapture(fCapture);}
  539. void TxSetFocus()
  540. {_phost->TxSetFocus();}
  541. // Allowed any-time
  542. BOOL TxShowScrollBar(INT fnBar, BOOL fShow);
  543. BOOL TxEnableScrollBar (INT fuSBFlags, INT fuArrowFlags);
  544. BOOL TxSetScrollRange(INT fnBar, LONG nMinPos, INT nMaxPos, BOOL fRedraw);
  545. BOOL TxSetScrollPos (INT fnBar, INT nPos, BOOL fRedraw);
  546. void TxInvalidate() {TxInvalidateRect((RECT*)NULL);}
  547. void TxInvalidateRect(const RECT* prc);
  548. void TxInvalidateRect(const RECTUV* prc);
  549. BOOL TxCreateCaret(HBITMAP hbmp, INT xWidth, INT yHeight)
  550. {return _phost->TxCreateCaret(hbmp, xWidth, yHeight);}
  551. BOOL TxShowCaret(BOOL fShow)
  552. {return _phost->TxShowCaret(fShow);}
  553. BOOL TxSetCaretPos(INT u, INT v);
  554. BOOL TxSetTimer(UINT idTimer, UINT uTimeout)
  555. {return _phost->TxSetTimer(idTimer, uTimeout);}
  556. void TxKillTimer(UINT idTimer)
  557. {_phost->TxKillTimer(idTimer);}
  558. COLORREF TxGetSysColor(int nIndex){ return _phost->TxGetSysColor(nIndex);}
  559. int TxWordBreakProc(TCHAR* pch, INT ich, INT cb, INT action, LONG cpStart, LONG cp = -1);
  560. // IME
  561. HIMC TxImmGetContext() {return _phost->TxImmGetContext();}
  562. void TxImmReleaseContext(HIMC himc)
  563. {_phost->TxImmReleaseContext( himc );}
  564. // Selection access
  565. CTxtSelection *GetSel();
  566. CTxtSelection *GetSelNC() { return _psel; }
  567. LONG GetSelMin() const;
  568. LONG GetSelMost() const;
  569. void GetSelRangeForRender(LONG *pcpSelMin, LONG *pcpSelMost);
  570. void DiscardSelection();
  571. // Property Change Helpers
  572. HRESULT OnRichEditChange(BOOL fFlag);
  573. HRESULT OnTxMultiLineChange(BOOL fMultiLine);
  574. HRESULT OnTxReadOnlyChange(BOOL fReadOnly);
  575. HRESULT OnShowAccelerator(BOOL fPropertyFlag);
  576. HRESULT OnUsePassword(BOOL fPropertyFlag);
  577. HRESULT OnTxHideSelectionChange(BOOL fHideSelection);
  578. HRESULT OnSaveSelection(BOOL fPropertyFlag);
  579. HRESULT OnTxVerticalChange(BOOL fVertical);
  580. HRESULT OnAutoWordSel(BOOL fPropertyFlag);
  581. HRESULT NeedViewUpdate(BOOL fPropertyFlag);
  582. HRESULT OnWordWrapChange(BOOL fPropertyFlag);
  583. HRESULT OnAllowBeep(BOOL fPropertyFlag);
  584. HRESULT OnDisableDrag(BOOL fPropertyFlag);
  585. HRESULT OnTxBackStyleChange(BOOL fPropertyFlag);
  586. HRESULT OnMaxLengthChange(BOOL fPropertyFlag);
  587. HRESULT OnCharFormatChange(BOOL fPropertyFlag);
  588. HRESULT OnParaFormatChange(BOOL fPropertyFlag);
  589. HRESULT OnClientRectChange(BOOL fPropertyFlag);
  590. HRESULT OnScrollChange(BOOL fProperyFlag);
  591. HRESULT OnSetTypographyOptions(WPARAM wparam, LPARAM lparam);
  592. HRESULT OnHideSelectionChange(BOOL fHideSelection);
  593. // Helpers
  594. HRESULT TxCharFromPos(LPPOINT ppt, LRESULT *pacp);
  595. HRESULT OnTxUsePasswordChange(BOOL fUsePassword);
  596. HRESULT FormatAndPrint(
  597. HDC hdcDraw,
  598. HDC hicTargetDev,
  599. DVTARGETDEVICE *ptd,
  600. RECT *lprcBounds,
  601. RECT *lprcWBounds);
  602. //
  603. // PUBLIC INTERFACE METHODS
  604. //
  605. // -----------------------------
  606. // IUnknown interface
  607. // -----------------------------
  608. virtual HRESULT WINAPI QueryInterface(REFIID riid, void **ppvObject);
  609. virtual ULONG WINAPI AddRef(void);
  610. virtual ULONG WINAPI Release(void);
  611. //--------------------------------------------------------------
  612. // ITextServices methods
  613. //--------------------------------------------------------------
  614. //@cmember Generic Send Message interface
  615. virtual HRESULT TxSendMessage(
  616. UINT msg,
  617. WPARAM wparam,
  618. LPARAM lparam,
  619. LRESULT *plresult);
  620. //@cmember Rendering
  621. virtual HRESULT TxDraw(
  622. DWORD dwDrawAspect, // draw aspect
  623. LONG lindex, // currently unused
  624. void * pvAspect, // info for drawing
  625. // optimizations (OCX 96)
  626. DVTARGETDEVICE * ptd, // information on target
  627. // device '
  628. HDC hdcDraw, // rendering device context
  629. HDC hicTargetDev, // target information
  630. // context
  631. LPCRECTL lprcBounds, // bounding (client)
  632. // rectangle
  633. LPCRECTL lprcWBounds, // clipping rect for
  634. // metafiles
  635. LPRECT lprcUpdate, // dirty rectange insde
  636. // lprcBounds
  637. BOOL (CALLBACK * pfnContinue) (DWORD), // for
  638. // interupting
  639. DWORD dwContinue, // long displays (currently
  640. // unused)
  641. LONG lViewID); // Specifies view to redraw
  642. //@cmember Horizontal scrollbar support
  643. virtual HRESULT TxGetHScroll(
  644. LONG *plMin,
  645. LONG *plMax,
  646. LONG *plPos,
  647. LONG *plPage,
  648. BOOL * pfEnabled );
  649. //@cmember Horizontal scrollbar support
  650. virtual HRESULT TxGetVScroll(
  651. LONG *plMin,
  652. LONG *plMax,
  653. LONG *plPos,
  654. LONG *plPage,
  655. BOOL * pfEnabled );
  656. //@cmember Setcursor
  657. virtual HRESULT OnTxSetCursor(
  658. DWORD dwDrawAspect, // draw aspect
  659. LONG lindex, // currently unused
  660. void * pvAspect, // info for drawing
  661. // optimizations (OCX 96)
  662. DVTARGETDEVICE * ptd, // information on target
  663. // device '
  664. HDC hdcDraw, // rendering device context
  665. HDC hicTargetDev, // target information
  666. // context
  667. LPCRECT lprcClient,
  668. INT x,
  669. INT y);
  670. //@cmember Hit-test
  671. virtual HRESULT TxQueryHitPoint(
  672. DWORD dwDrawAspect, // draw aspect
  673. LONG lindex, // currently unused
  674. void * pvAspect, // info for drawing
  675. // optimizations (OCX 96)
  676. DVTARGETDEVICE * ptd, // information on target
  677. // device '
  678. HDC hdcDraw, // rendering device context
  679. HDC hicTargetDev, // target information
  680. // context
  681. LPCRECT lprcClient,
  682. INT x,
  683. INT y,
  684. DWORD * pHitResult);
  685. //@member Inplace activate notification
  686. virtual HRESULT OnTxInPlaceActivate(const RECT *prcClient);
  687. //@member Inplace deactivate notification
  688. virtual HRESULT OnTxInPlaceDeactivate();
  689. //@member UI activate notification
  690. virtual HRESULT OnTxUIActivate();
  691. //@member UI deactivate notification
  692. virtual HRESULT OnTxUIDeactivate();
  693. //@member Get text in control
  694. virtual HRESULT TxGetText(BSTR *pbstrText);
  695. //@member Set text in control
  696. virtual HRESULT TxSetText(LPCTSTR pszText);
  697. //@member Get x position of
  698. virtual HRESULT TxGetCurTargetX(LONG *);
  699. //@member Get baseline position
  700. virtual HRESULT TxGetBaseLinePos(LONG *);
  701. //@member Get Size to fit / Natural size
  702. virtual HRESULT TxGetNaturalSize(
  703. DWORD dwAspect,
  704. HDC hdcDraw,
  705. HDC hicTargetDev,
  706. DVTARGETDEVICE *ptd,
  707. DWORD dwMode,
  708. const SIZEL *psizelExtent,
  709. LONG *pwidth,
  710. LONG *pheight);
  711. //@member Drag & drop
  712. virtual HRESULT TxGetDropTarget( IDropTarget **ppDropTarget );
  713. //@member Bulk bit property change notifications
  714. virtual HRESULT OnTxPropertyBitsChange(DWORD dwMask, DWORD dwBits);
  715. //@cmember Fetch the cached drawing size
  716. virtual HRESULT TxGetCachedSize(DWORD *pdupClient, DWORD *pdvpClient);
  717. // IDispatch methods
  718. STDMETHOD(GetTypeInfoCount)( UINT * pctinfo);
  719. STDMETHOD(GetTypeInfo)(
  720. UINT itinfo,
  721. LCID lcid,
  722. ITypeInfo **pptinfo);
  723. STDMETHOD(GetIDsOfNames)(
  724. REFIID riid,
  725. OLECHAR **rgszNames,
  726. UINT cNames,
  727. LCID lcid,
  728. DISPID * rgdispid);
  729. STDMETHOD(Invoke)(
  730. DISPID dispidMember,
  731. REFIID riid,
  732. LCID lcid,
  733. WORD wFlags,
  734. DISPPARAMS * pdispparams,
  735. VARIANT * pvarResult,
  736. EXCEPINFO * pexcepinfo,
  737. UINT * puArgErr);
  738. // ITextDocument2 methods
  739. STDMETHOD(GetName)(BSTR *pName);
  740. STDMETHOD(GetSelection)(ITextSelection **ppSel);
  741. STDMETHOD(GetStoryCount)(long *pCount);
  742. STDMETHOD(GetStoryRanges)(ITextStoryRanges **ppStories);
  743. STDMETHOD(GetSaved)(long *pValue);
  744. STDMETHOD(SetSaved)(long Value);
  745. STDMETHOD(GetDefaultTabStop)(float *pValue);
  746. STDMETHOD(SetDefaultTabStop)(float Value);
  747. STDMETHOD(New)();
  748. STDMETHOD(Open)(VARIANT *pVar, long Flags, long CodePage);
  749. STDMETHOD(Save)(VARIANT *pVar, long Flags, long CodePage);
  750. STDMETHOD(Freeze)(long *pCount);
  751. STDMETHOD(Unfreeze)(long *pCount);
  752. STDMETHOD(BeginEditCollection)();
  753. STDMETHOD(EndEditCollection)();
  754. STDMETHOD(Undo)(long Count, long *prop);
  755. STDMETHOD(Redo)(long Count, long *prop);
  756. STDMETHOD(Range)(long cpFirst, long cpLim, ITextRange ** ppRange);
  757. STDMETHOD(RangeFromPoint)(long x, long y, ITextRange **ppRange);
  758. STDMETHOD(AttachMsgFilter)(IUnknown *pFilter);
  759. STDMETHOD(GetEffectColor)( long Index, COLORREF *pcr);
  760. STDMETHOD(SetEffectColor)( long Index, COLORREF cr);
  761. STDMETHOD(GetCaretType)( long *pCaretType);
  762. STDMETHOD(SetCaretType)( long CaretType);
  763. STDMETHOD(GetImmContext)( long *pContext);
  764. STDMETHOD(ReleaseImmContext)( long Context);
  765. STDMETHOD(GetPreferredFont)( long cp, long CodePage, long lOption, long curCodepage,
  766. long curFontSize, BSTR *pFontName, long *pPitchAndFamily, long *pNewFontSize);
  767. STDMETHOD(GetNotificationMode)( long *plMode);
  768. STDMETHOD(SetNotificationMode)( long lMode);
  769. STDMETHOD(GetClientRect)( long Type, long *pLeft, long *pTop, long *pRight, long *pBottom);
  770. STDMETHOD(GetSelectionEx)(ITextSelection **ppSel);
  771. STDMETHOD(GetWindow)( long *phWnd );
  772. STDMETHOD(GetFEFlags)( long *pFlags );
  773. STDMETHOD(UpdateWindow)( void );
  774. STDMETHOD(CheckTextLimit)( long cch, long *pcch );
  775. STDMETHOD(IMEInProgress)( long lMode );
  776. STDMETHOD(SysBeep)( void );
  777. STDMETHOD(Update)( long lMode );
  778. STDMETHOD(Notify)( long lNotify );
  779. STDMETHOD(GetDocumentFont)( ITextFont **ppITextFont );
  780. STDMETHOD(GetDocumentPara)( ITextPara **ppITextPara );
  781. STDMETHOD(GetCallManager)( IUnknown **ppVoid );
  782. STDMETHOD(ReleaseCallManager)( IUnknown *pVoid );
  783. // IRichEditOle methods
  784. STDMETHOD(GetClientSite) ( LPOLECLIENTSITE *lplpolesite);
  785. STDMETHOD_(LONG,GetObjectCount) (THIS);
  786. STDMETHOD_(LONG,GetLinkCount) (THIS);
  787. STDMETHOD(GetObject) ( LONG iob, REOBJECT *lpreobject,
  788. DWORD dwFlags);
  789. STDMETHOD(InsertObject) ( REOBJECT *lpreobject);
  790. STDMETHOD(ConvertObject) ( LONG iob, REFCLSID rclsidNew,
  791. LPCSTR lpstrUserTypeNew);
  792. STDMETHOD(ActivateAs) ( REFCLSID rclsid, REFCLSID rclsidAs);
  793. STDMETHOD(SetHostNames) ( LPCSTR lpstrContainerApp,
  794. LPCSTR lpstrContainerObj);
  795. STDMETHOD(SetLinkAvailable) ( LONG iob, BOOL fAvailable);
  796. STDMETHOD(SetDvaspect) ( LONG iob, DWORD dvaspect);
  797. STDMETHOD(HandsOffStorage) ( LONG iob);
  798. STDMETHOD(SaveCompleted) ( LONG iob, LPSTORAGE lpstg);
  799. STDMETHOD(InPlaceDeactivate) (THIS);
  800. STDMETHOD(ContextSensitiveHelp) ( BOOL fEnterMode);
  801. STDMETHOD(GetClipboardData) ( CHARRANGE *lpchrg, DWORD reco,
  802. LPDATAOBJECT *lplpdataobj);
  803. STDMETHOD(ImportDataObject) ( LPDATAOBJECT lpdataobj,
  804. CLIPFORMAT cf, HGLOBAL hMetaPict);
  805. private:
  806. // Get/Set text helpers
  807. LONG GetTextRange(LONG cpFirst, LONG cch, TCHAR *pch);
  808. LONG GetTextEx(GETTEXTEX *pgt, TCHAR *pch);
  809. LONG GetTextLengthEx(GETTEXTLENGTHEX *pgtl);
  810. //--------------------------------------------------------------
  811. // WinProc dispatch methods
  812. // Internally called by the WinProc
  813. //--------------------------------------------------------------
  814. // Keyboard
  815. HRESULT OnTxKeyDown (WORD vkey, DWORD dwFlags, IUndoBuilder *publdr);
  816. HRESULT OnTxChar (DWORD vkey, DWORD dwFlags, IUndoBuilder *publdr);
  817. HRESULT OnTxSysChar (WORD vkey, DWORD dwFlags, IUndoBuilder *publdr);
  818. HRESULT OnTxSysKeyDown (WORD vkey, DWORD dwFlags, IUndoBuilder *publdr);
  819. HRESULT OnTxSpecialKeyDown(WORD vkey, DWORD dwFlags, IUndoBuilder *publdr);
  820. // Mouse
  821. HRESULT OnTxLButtonDblClk(INT x, INT y, DWORD dwFlags);
  822. HRESULT OnTxLButtonDown (INT x, INT y, DWORD dwFlags);
  823. HRESULT OnTxLButtonUp (INT x, INT y, DWORD dwFlags, int ffOptions);
  824. HRESULT OnTxRButtonDown (INT x, INT y, DWORD dwFlags);
  825. HRESULT OnTxRButtonUp (INT x, INT y, DWORD dwFlags, int ffOptions);
  826. HRESULT OnTxMouseMove (INT x, INT y, DWORD dwFlags, IUndoBuilder *publdr);
  827. HRESULT OnTxMButtonDown (INT x, INT y, DWORD dwFlags);
  828. HRESULT OnTxMButtonUp (INT x, INT y, DWORD dwFlags);
  829. // Timer
  830. HRESULT OnTxTimer(UINT idTimer);
  831. void CheckInstallContinuousScroll ();
  832. void CheckRemoveContinuousScroll ();
  833. // Scrolling
  834. HRESULT TxLineScroll(LONG cli, LONG cach);
  835. // Magellan mouse scrolling
  836. BOOL StopMagellanScroll();
  837. // Paint, size message
  838. LRESULT OnSize(HWND hwnd, WORD fwSizeType, int nWidth, int nHeight);
  839. // Selection commands
  840. LRESULT OnGetSelText(TCHAR *psz);
  841. LRESULT OnGetSel(LONG *pacpMin, LONG *pacpMost);
  842. LRESULT OnSetSel(LONG acpMin, LONG acpMost);
  843. void OnExGetSel(CHARRANGE *pcr);
  844. // Editing commands
  845. void OnClear(IUndoBuilder *publdr);
  846. // Format range related commands
  847. LRESULT OnFormatRange(FORMATRANGE *pfr, SPrintControl prtcon, BOOL fSetupDC = FALSE);
  848. BOOL OnDisplayBand(const RECT *prcView, BOOL fPrintFromDraw);
  849. // Scrolling commands
  850. void OnScrollCaret();
  851. // Focus messages
  852. LRESULT OnSetFocus();
  853. LRESULT OnKillFocus();
  854. // System notifications
  855. HRESULT OnContextMenu(LPARAM lparam);
  856. // Get/Set other properties commands
  857. LRESULT OnFindText(UINT msg, DWORD flags, FINDTEXTEX *pftex);
  858. LRESULT OnSetWordBreakProc();
  859. // Richedit stuff
  860. LRESULT OnGetCharFormat(CHARFORMAT2 *pCF2, DWORD dwFlags);
  861. LRESULT OnGetParaFormat(PARAFORMAT2 *pPF2, DWORD dwFlags);
  862. LRESULT OnSetCharFormat(WPARAM wparam, CCharFormat *pCF, IUndoBuilder *publdr,
  863. DWORD dwMask, DWORD dwMask2);
  864. LRESULT OnSetParaFormat(WPARAM wparam, CParaFormat *pPF, IUndoBuilder *publdr,
  865. DWORD dwMask, DWORD dwMask2);
  866. LRESULT OnSetFont(HFONT hfont);
  867. LRESULT OnSetFontSize(LONG yPoint, DWORD dwFlags, IUndoBuilder *publdr);
  868. LRESULT OnDropFiles(HANDLE hDropFiles);
  869. LRESULT OnGetAssociateFont(CHARFORMAT2 *pCF, DWORD dwFlags);
  870. LRESULT OnSetAssociateFont(CHARFORMAT2 *pCF, DWORD dwFlags);
  871. // Other services
  872. HRESULT TxPosFromChar(LONG acp, LPPOINT ppt);
  873. HRESULT TxGetLineCount(LRESULT *plres);
  874. HRESULT TxLineFromCp(LONG acp, LRESULT *plres);
  875. HRESULT TxLineLength(LONG acp, LRESULT *plres);
  876. HRESULT TxLineIndex (LONG ili, LRESULT *plres);
  877. HRESULT TxFindText(DWORD flags, LONG acpMin, LONG acpMost, const WCHAR *pch,
  878. LONG *pacpMin, LONG *pacpMost);
  879. HRESULT TxFindWordBreak(INT nFunction, LONG acp, LRESULT *plres);
  880. HRESULT SetText(LPCWSTR pwszText, DWORD flags, LONG CodePage,
  881. IUndoBuilder *publdr = NULL, LRESULT *plres = NULL);
  882. LONG GetDefaultCodePage(UINT msg);
  883. HRESULT OnInsertTable(TABLEROWPARMS *ptrp, TABLECELLPARMS *pclp, IUndoBuilder *publdr);
  884. // Other miscelleneous
  885. #if defined(DEBUG) && !defined(NOFULLDEBUG)
  886. void OnDumpPed();
  887. #endif
  888. COleObject * ObjectFromIOB(LONG iob);
  889. // Only when the selection is going away should this value be NULLed. We
  890. // use SelectionNull function rather than CTxtSelection::~CTxtSelection
  891. // to avoid circular dependencies.
  892. friend void SelectionNull(CTxtEdit *ped);
  893. void SetSelectionToNull()
  894. {if(_fFocus)
  895. DestroyCaret();
  896. _psel = NULL;
  897. }
  898. // Helper for converting a rich text object to plain text.
  899. void HandleRichToPlainConversion();
  900. // Helper for clearing the undo buffers.
  901. void ClearUndo(IUndoBuilder *publdr);
  902. // Helper for setting the automatic EOP
  903. void SetRichDocEndEOP(LONG cchToReplace);
  904. LRESULT CTxtEdit::InsertFromFile ( LPCTSTR lpFile );
  905. //
  906. // Data Members
  907. //
  908. public:
  909. static DWORD _dwTickDblClick; // time of last double-click
  910. static POINT _ptDblClick; // position of last double-click
  911. static HCURSOR _hcurArrow;
  912. // static HCURSOR _hcurCross; // OutlineSymbol drag not impl
  913. static HCURSOR _hcurHand;
  914. static HCURSOR _hcurIBeam;
  915. static HCURSOR _hcurItalic;
  916. static HCURSOR _hcurSelBar;
  917. static HCURSOR _hcurVIBeam;
  918. static HCURSOR _hcurVItalic;
  919. typedef HRESULT (CTxtEdit::*FNPPROPCHG)(BOOL fPropFlag);
  920. static FNPPROPCHG _fnpPropChg[MAX_PROPERTY_BITS];
  921. QWORD _qwCharFlags;// Char flags for text in control
  922. // Only wrapper functions should use this member...
  923. ITextHost2* _phost; // host
  924. // word break procedure
  925. EDITWORDBREAKPROC _pfnWB; // word break procedure
  926. // display subsystem
  927. CDisplay * _pdp; // display
  928. CDisplayPrinter * _pdpPrinter;// display for printer
  929. // undo
  930. IUndoMgr * _pundo; // the undo stack
  931. IUndoMgr * _predo; // the redo stack
  932. // data transfer
  933. CLightDTEngine _ldte; // the data transfer engine
  934. CNotifyMgr _nm; // the notification manager (for floating
  935. // OLE support
  936. CObjectMgr * _pobjmgr; // handles most high-level OLE stuff
  937. // Re-entrancy && Notification Management
  938. CCallMgr * _pcallmgr;
  939. // URL detection
  940. CDetectURL * _pdetecturl;// manages auto-detection of URL strings
  941. CDocInfo * _pDocInfo; // Document info (name, flags, code page)
  942. CTxtBreaker * _pbrk; // text-breaker object
  943. DWORD _dwEventMask; // Event mask
  944. union
  945. {
  946. DWORD _dwFlags; // All together now
  947. struct
  948. {
  949. #define TXTBITS (TXTBIT_RICHTEXT | \
  950. TXTBIT_READONLY | \
  951. TXTBIT_USEPASSWORD | \
  952. TXTBIT_HIDESELECTION | \
  953. TXTBIT_VERTICAL | \
  954. TXTBIT_ALLOWBEEP | \
  955. TXTBIT_DISABLEDRAG )
  956. // State information. Flags in TXTBITS must appear in same bit
  957. // positions as the following (saves code in Init())
  958. // TXTBIT_RICHTEXT 0 _fRich
  959. // TXTBIT_MULTILINE 1
  960. // TXTBIT_READONLY 2 _fReadOnly
  961. // TXTBIT_SHOWACCELERATOR 3
  962. // TXTBIT_USEPASSWORD 4 _fUsePassword
  963. // TXTBIT_HIDESELECTION 5 _fHideSelection
  964. // TXTBIT_SAVESELECTION 6
  965. // TXTBIT_AUTOWORDSEL 7
  966. // TXTBIT_VERTICAL 8
  967. // TXTBIT_SELECTIONBAR 9
  968. // TXTBIT_WORDWRAP 10
  969. // TXTBIT_ALLOWBEEP 11 _fAllowBeep
  970. // TXTBIT_DISABLEDRAG 12 _fDisableDrag
  971. // TXTBIT_VIEWINSETCHANGE 13
  972. // TXTBIT_BACKSTYLECHANGE 14
  973. // TXTBIT_MAXLENGTHCHANGE 15
  974. // TXTBIT_SCROLLBARCHANGE 16
  975. // TXTBIT_CHARFORMATCHANGE 17
  976. // TXTBIT_PARAFORMATCHANGE 18
  977. // TXTBIT_EXTENTCHANGE 19
  978. // TXTBIT_CLIENTRECTCHANGE 20
  979. DWORD _fRich :1; // 0: Use rich-text formatting
  980. DWORD _fCapture :1; // 1: Control has mouse capture
  981. DWORD _fReadOnly :1; // 2: Control is read only
  982. DWORD _fInPlaceActive :1; // 3: Control is in place active
  983. DWORD _fUsePassword :1; // 4: Whether to use password char
  984. DWORD _fHideSelection :1; // 5: Hide selection when inactive
  985. DWORD _fOverstrike :1; // 6: Overstrike mode vs insert mode
  986. DWORD _fFocus :1; // 7: Control has keyboard focus
  987. DWORD _fEatLeftDown :1; // 8: Eat the next left down?
  988. DWORD _fMouseDown :1; // 9: One mouse button is current down
  989. DWORD _fTransparent :1; // 10: Background transparency
  990. DWORD _fAllowBeep :1; // 11: Allow beep at doc boundaries
  991. DWORD _fDisableDrag :1; // 12: Disable Drag
  992. DWORD _fIconic :1; // 13: Control/parent window is iconized
  993. DWORD _fModified :1; // 14: Control text has been modified
  994. DWORD _fScrollCaretOnFocus:1; // 15: Scroll caret into view on set focus
  995. DWORD _fStreaming :1; // 16: Currently streaming text in or out
  996. DWORD _fWantDrag :1; // 17: Want to initiate drag & drop
  997. DWORD _fRichPrevAccel :1; // 18: Rich state previous to accelerator
  998. // Miscellaneous bits
  999. DWORD _f10Mode :1; // 19: Use Richedit10 behavior
  1000. DWORD _fUseUndo :1; // 20: Only set to zero if undo limit is 0
  1001. // Font binding (see also _fAutoFontSizeAdjust)
  1002. DWORD _fAutoFont :1; // 21: auto switching font
  1003. DWORD _fAutoKeyboard :1; // 22: auto switching keyboard
  1004. DWORD _fContinuousScroll :1; // 23: Timer runs to support scrolling
  1005. DWORD _fMButtonCapture :1; // 24: captured mButton down
  1006. DWORD _fHost2 :1; // 25: TRUE iff _phost is a phost2
  1007. DWORD _fSaved :1; // 26: ITextDocument Saved property
  1008. DWORD _fInOurHost :1; // 27: Whether we are in our host
  1009. DWORD _fCheckAIMM :1; // 28: if FALSE check if client has loaded AIMM
  1010. DWORD _fKoreanBlockCaret :1; // 29: Display Korean block caret during Kor IME
  1011. // Drag/Drop UI refinement.
  1012. DWORD _fDragged :1; // 30: Was the selection actually dragged?
  1013. DWORD _fUpdateSelection :1; // 31: If true, update sel at level 0
  1014. };
  1015. };
  1016. #define CD_LTR 2
  1017. #define CD_RTL 3
  1018. WORD _nContextDir :2; // 0: no context; else CD_LTR or CD_RTL
  1019. WORD _nContextAlign :2; // Current context alignment; default CTX_NONE
  1020. WORD _fNeutralOverride :1; // Override direction of neutrals for layout
  1021. WORD _fSuppressNotify :1; // Don't send SelChange Notification if True
  1022. WORD _cActiveObjPosTries :2; // Counter protecting against infinite repaint
  1023. // loop when trying to put dragged-away
  1024. // in-place active object where it belongs
  1025. WORD _fSingleCodePage :1; // If TRUE, only allow single code page
  1026. // (currently doesn't check streaming...)
  1027. WORD _fSelfDestruct :1; // This CTxtEdit is selfdestructing
  1028. WORD _fAutoFontSizeAdjust:1; // Auto switching font size adjust
  1029. // Miscellaneous bits used for BiDi input
  1030. WORD _fHbrCaps :1; // Initialization of state of hebrew and caps lock status
  1031. WORD _fActivateKbdOnFocus:1; // Activate new kbd layout on WM_SETFOCUS
  1032. WORD _fOutlineView :1; // Outline view is active
  1033. WORD _fPageView :1; // Page view is active
  1034. // More IME bit
  1035. WORD _fIMEInProgress :1; // TRUE if IME composition is in progress
  1036. WORD _ClipboardFormat :5; // Last clipboard format used (see EN_CLIPFORMAT)
  1037. // Shutdown bit
  1038. WORD _fReleaseHost :1; // TRUE if edit control needs to release host in
  1039. // edit control destructor.
  1040. WORD _fOOMNotified :1; // flag determining if a OOM notification was already sent
  1041. WORD _fDualFont :1; // Dual font support for FE typing
  1042. // Default = TRUE
  1043. WORD _fUIFont :1; // If TRUE, use UI font
  1044. WORD _fItemizePending :1; // Updated range hasn't been itemized
  1045. WORD _fSelChangeCharFormat :1; // TRUE if the selection has been used to change
  1046. // the character format of a specific set of
  1047. // characters. The purpose of this has to do with
  1048. // maintaining the illusion of having a default
  1049. // charformat on machines whose default language
  1050. // is a complex script i.e. Arabic. The idea is
  1051. // that all EM_SETCHARFORMAT messages that would
  1052. // just update the default format, are converted
  1053. // to SCF_ALL so that all the text has the change
  1054. // applied to it. Bug 5462 caused this change.
  1055. // (a-rsail).
  1056. WORD _fExWordBreakProc :1; // detemines which WordbreakProc Callback to use
  1057. // Extended or regular
  1058. WORD _f10DeferChangeNotify :1; // 1.0 mode immulation, defer selection change
  1059. // notification until the mouse is up
  1060. union
  1061. {
  1062. DWORD _dwEditStyle;
  1063. struct
  1064. {
  1065. DWORD _fSystemEditMode :1; // 1: Behave more like sys edit
  1066. DWORD _fSystemEditBeep :1; // 2: Beep when system edit does
  1067. DWORD _fExtendBackColor :1; // 4: Extend BkClr to margin
  1068. DWORD _fUnusedEditStyle1 :1; // 8: SES_MAPCPS not used
  1069. DWORD _fUnusedEditStyle2 :1; // 16: SES_EMULATE10 not used
  1070. DWORD _fUnusedEditStyle3 :1; // 32: SES_USECRLF not used
  1071. DWORD _fUnusedEditStyle4 :1; // 64: SES_USEAIMM handled in cmsgflt
  1072. DWORD _fUnusedEditStyle5 :1; // 128: SES_NOIME handled in cmsgflt
  1073. DWORD _fUnusedEditStyle6 :1; // 256: SES_ALLOWBEEPS not used
  1074. DWORD _fUpperCase :1; // 512: Convert all input to upper case
  1075. DWORD _fLowerCase :1; // 1024: Convert all input to lower case
  1076. DWORD _fNoInputSequenceChk:1; // 2048: Disable ISCheck
  1077. DWORD _fBiDi :1; // 4096: Set Bidi document
  1078. DWORD _fScrollCPOnKillFocus:1;// 8192: Scroll to cp=0 upon Kill focus
  1079. DWORD _fXltCRCRLFtoCR :1; // 16384: Translate CRCRLF to CR instead of ' '
  1080. DWORD _fDraftMode :1; // 32768: Use draftmode fonts
  1081. DWORD _fUseCTF :1; // 0x010000: SES_USECTF handled in cmsgflt
  1082. DWORD _fHideGridlines :1; // 0x020000: if 0-width gridlines not displayed
  1083. DWORD _fUseAtFont :1; // 0x040000: use @ font
  1084. DWORD _fCustomLook :1; // 0x080000: use new look
  1085. DWORD _fLBScrollNotify :1; // 0x100000: REListbox - notify before/after scroll window
  1086. };
  1087. };
  1088. void (WINAPI* _pfnHyphenate)(WCHAR*, LANGID, long, HYPHRESULT*);
  1089. SHORT _dulHyphenateZone; // Hyphenation zone
  1090. ITextMsgFilter * _pMsgFilter; // Pointer to message filter.
  1091. #ifndef NOPRIVATEMESSAGE
  1092. CMsgCallBack * _pMsgCallBack;
  1093. CTextNotify * _pMsgNotify;
  1094. #endif
  1095. private:
  1096. SHORT _cpAccelerator; // Range for accelerator
  1097. BYTE _bTypography; // Typography options
  1098. BYTE _bMouseFlags; // CTRL, Mouse buttons, SHIFT
  1099. SHORT _cFreeze; // Freeze count
  1100. WORD _wZoomNumerator;
  1101. WORD _wZoomDenominator;
  1102. // Have to have mouse point on a per-instance basis to handle
  1103. // simultaneous scrolling of two or more controls.
  1104. // TODO: convert this back to DWORD from whence it came (lparam)
  1105. POINT _mousePt; // Last known mouse position.
  1106. // NOTE: the int's can be switched to SHORTs, since pixels are used and
  1107. // 32768 pixels is a mighty big screen!
  1108. DWORD _cchTextMost; // Maximum allowed text
  1109. LONG _cpFirstStrong; // cp of first strong directional character.
  1110. // used for plain text controls whose direcitonality
  1111. // depends on text input into the control.
  1112. friend class CRchTxtPtr;
  1113. IUnknown * _punk; // IUnknown to use
  1114. class CUnknown : public IUnknown
  1115. {
  1116. friend class CCallMgr;
  1117. private:
  1118. DWORD _cRefs; // Reference count
  1119. public:
  1120. void Init() {_cRefs = 1; }
  1121. HRESULT WINAPI QueryInterface(REFIID riid, void **ppvObj);
  1122. ULONG WINAPI AddRef();
  1123. ULONG WINAPI Release();
  1124. };
  1125. friend class CUnknown;
  1126. CUnknown _unk; // Object that implements IUnknown
  1127. CTxtStory _story;
  1128. CTxtSelection * _psel; // Selection object
  1129. };
  1130. extern const COLORREF g_Colors[];
  1131. class CCellColor
  1132. {
  1133. public:
  1134. COLORREF _crCellCustom1; // Custom color 1
  1135. COLORREF _crCellCustom2; // Custom color 2
  1136. CCellColor() {_crCellCustom1 = _crCellCustom2 = 0;}
  1137. LONG GetColorIndex(COLORREF cr);
  1138. };
  1139. #endif