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.

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