_edit.h
来自「Windows CE 6.0 Word Application 源码」· C头文件 代码 · 共 1,115 行 · 第 1/3 页
H
1,115 行
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft shared
// source or premium shared source license agreement under which you licensed
// this source code. If you did not accept the terms of the license agreement,
// you are not authorized to use this source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the SOURCE.RTF on your install media or the root of your tools installation.
// THE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
/* _EDIT.H
*
* Purpose:
* Base classes for rich-text manipulation
*
* Authors:
* Christian Fortini
* Murray Sargent
*
*/
#ifndef _EDIT_H
#define _EDIT_H
#include "textserv.h"
#include "_ldte.h"
#include "_m_undo.h"
#include "_notmgr.h"
#include "_doc.h"
#include "_objmgr.h"
#include "_cfpf.h"
#include "_callmgr.h"
#include "_magelln.h"
// Forward declarations
class CRchTxtPtr;
class CTxtSelection;
class CTxtStory;
class CTxtUndo;
class CMeasurer;
class CRenderer;
class CDisplay;
class CDisplayPrinter;
class CDrawInfo;
class CDetectURL;
class CBiDiEngine;
// Macro for finding parent "this" of embedded class. If this turns out to be
// globally useful we should move it to _common.h.
#define GETPPARENT(pmemb, struc, membname) (\
(struc FAR *)(((char FAR *)(pmemb))-offsetof(struc, membname)))
// These wonderful constants are for backward compatibility. They are the
// sizes used for initialization and reset in RichEdit 1.0
const LONG cInitTextMax = (32 * 1024) - 1;
const LONG cResetTextMax = (64 * 1024);
// NB! Global variable that tells us wether we're on a BiDi system or not
extern WORD g_wLang; // Current LID of the system:
// Arabic, Hebrew or "nonBiDi"
#define IsBiDiSystem() (g_wLang != sLanguageNonBiDi)
extern WORD g_wFlags; // Toggled by Ctrl-"
#define KF_SMARTQUOTES 0x0001 // Enable smart quotes
#define SmartQuotesEnabled() (g_wFlags & KF_SMARTQUOTES)
struct SPrintControl
{
union
{
DWORD _dwAllFlags; // Make it easy to set all flags at once.
struct
{
ULONG _fDoPrint:1; // Whether actual print is required
ULONG _fPrintFromDraw:1; // Whether draw is being used to print
};
};
SPrintControl(void) { _dwAllFlags = 0; }
};
enum DOCUMENTTYPE
{
DT_LTRDOC = 1, // DT_LTRDOC and DT_RTLDOC are mutually
DT_RTLDOC = 2, // exclusive
};
class CDocInfo // Contains ITextDocument info
{
public:
BSTR pName; // Document filename
HANDLE hFile; // Handle used unless full file sharing
WORD wFlags; // Open, share, create, and save flags
WORD wCpg; // Code page
LONG dwDefaultTabStop; // TOM settable default tab stop
LCID lcid; // Document lcid (for RTF \deflang)
LCID lcidfe; // Document FE lcid (for RTF \deflangfe)
LPWSTR lpstrLeadingPunct; // Leading kinsoku characters
LPWSTR lpstrFollowingPunct;// Following kinsoku characters
BYTE bDocType; // 0-1-2: export none-\ltrdoc-\rtldoc
// If 0x80 or'd in, PWD instead of RTF
CDocInfo() {InitDocInfo();} // constructor
~CDocInfo(); // destructor
void InitDocInfo();
};
const DWORD tomInvalidCpg = 0xFFFF;
const DWORD tomInvalidLCID = 0xFFFE;
#define tomOutline 1
// This depends on the number of property bits defined in textserv.h. However, this is
// for private use by the text services so it is defined here.
#define MAX_PROPERTY_BITS 21
#define SPF_SETDEFAULT 4
#define SFF_ADJUSTENDEOP 0x80000000
#define SFF_KEEPDOCINFO 0x40000000
// IDispatch global declarations
extern ITypeInfo * g_pTypeInfoDoc;
extern ITypeInfo * g_pTypeInfoSel;
extern ITypeInfo * g_pTypeInfoFont;
extern ITypeInfo * g_pTypeInfoPara;
HRESULT GetTypeInfoPtrs();
HRESULT GetTypeInfo(UINT iTypeInfo, ITypeInfo *&pTypeInfo,
ITypeInfo **ppTypeInfo);
LONG Cleanse(TCHAR * pchD, const TCHAR * pchS, LONG cchS);
/*
* @enum flags indicating how protection should be dealt with
* in CTxtEdit::SetText
*/
enum SetTextFlags
{
CHECK_PROTECTION = 1, //@emem check for protection
IGNORE_PROTECTION = 2, //@emem ignore any protection (even if found)
};
enum AccentIndices
{
ACCENT_GRAVE = 1,
ACCENT_ACUTE,
ACCENT_CARET,
ACCENT_TILDE,
ACCENT_UMLAUT,
ACCENT_CEDILLA
};
// ================================== CTxtEdit ============================================
// Outer most class for a Text Control.
class CTxtEdit : public ITextServices, public IRichEditOle, public ITextDocument
{
public:
friend class CCallMgr;
friend class CMagellanBMPStateWrap;
friend void CheckDestroyIME ( CTxtEdit &ed );
CTxtEdit(ITextHost *phost, IUnknown *punkOuter);
~CTxtEdit ();
// Initialization
BOOL Init(const RECT *prcClient);
// A helper function
DWORD GetTextLength() const {return _story.GetTextLength();}
DWORD GetAdjustedTextLength();
// Access to ActiveObject members
IUnknown * GetPrivateIUnknown() { return &_unk; }
CLightDTEngine *GetDTE() { return &_ldte; }
IUndoMgr * GetUndoMgr() { return _pundo; }
IUndoMgr * GetRedoMgr() { return _predo; }
IUndoMgr * CreateUndoMgr(DWORD dwLim, USFlags flags);
CCallMgr * GetCallMgr() {
Assert(_pcallmgr);
return _pcallmgr;
}
CObjectMgr * GetObjectMgr();
// the callback is provided by the client
// to help with OLE support
BOOL HasObjects() {return !!_pobjmgr;}
IRichEditOleCallback *GetRECallback()
{ return _pobjmgr ? _pobjmgr->GetRECallback() : NULL; }
LRESULT HandleSetUndoLimit(DWORD dwLim);
LRESULT HandleSetTextMode(DWORD mode);
CNotifyMgr * GetNotifyMgr();
CDetectURL * GetDetectURL() {return _pdetecturl;}
CBiDiEngine * GetBiDiEngine() {return NULL;}
BOOL IsBiDiEngineValid() {return _pBiDiEngine != NULL;}
#if !defined(NOMAGELLAN)
CMagellan mouse;
LRESULT HandleMouseWheel(WPARAM wparam, LPARAM lparam);
#endif
// Misc helpers
BOOL Get10Mode() {return _f10Mode;}
LONG GetCpAccelerator() const {return _cpAccelerator;}
BOOL fInOurHost() const {return _fInOurHost;}
BOOL fInplaceActive() const {return _fInPlaceActive;}
BOOL fHideSelection() const {return _fHideSelection;}
BOOL fUsePassword() const {return _fUsePassword;}
BOOL IsInOutlineView() const {return _fOutlineView;}
BOOL IsMouseDown() const {return _fMouseDown;}
BOOL IsRich() const {return _fRich;}
LONG GetZoomNumerator() const {return _wZoomNumerator;}
LONG GetZoomDenominator() const {return _wZoomDenominator;}
void SetZoomNumerator(LONG x) {_wZoomNumerator = x;}
void SetZoomDenominator(LONG x) {_wZoomDenominator = x;}
void CheckUnicode(LONG lStreamFormat);
void HandleKbdContextMenu(void);
void Set10Mode();
void Sound();
HRESULT UpdateAccelerator();
HRESULT UpdateOutline();
HRESULT PopAndExecuteAntiEvent(
IUndoMgr *pundomgr,
DWORD dwDoToCookie);
HRESULT CutOrCopySelection(UINT msg, WPARAM wparam, LPARAM lparam,
IUndoBuilder *publdr);
HRESULT PasteDataObjectToRange(
IDataObject *pdo,
CTxtRange *prg,
CLIPFORMAT cf,
REPASTESPECIAL *rps,
IUndoBuilder *publdr,
DWORD dwFlags );
HRESULT MoveSelection(
LPARAM lparam,
IUndoBuilder *publdr);
HDC CreateMeasureDC(
HDC hdcMetaFile,
const RECT *prcClient,
BOOL fUseTwips,
LONG xWindowOrg,
LONG yWindowOrg,
LONG xWindowExt,
LONG yWindowExt,
LONG *pxPerInch,
LONG *pyPerInch);
void SetContextDirection();
// Story access
CTxtStory * GetTxtStory () { return &_story; }
// Get access to cached CCharFormat and CParaFormat structures
const CCharFormat* GetCharFormat(LONG icf);
const CParaFormat* GetParaFormat(LONG ipf);
HRESULT HandleStyle(CCharFormat *pCFTarget, const CCharFormat *pCF);
HRESULT HandleStyle(CParaFormat *pPFTarget, const CParaFormat *pPF);
// Get the host interface pointer
ITextHost * GetHost() { return _phost; }
// Helper for getting the CDocInfo ptr and creating it if it's NULL
CDocInfo * GetDocInfo();
HRESULT InitDocInfo();
LONG GetDefaultTab()
{return _pDocInfo ? _pDocInfo->dwDefaultTabStop : lDefaultTab;};
HRESULT SetDefaultLCID (LCID lcid);
HRESULT GetDefaultLCID (LCID *pLCID);
HRESULT SetDefaultLCIDFE (LCID lcid);
HRESULT GetDefaultLCIDFE (LCID *pLCID);
HRESULT SetDocumentType (LONG DocType);
HRESULT GetDocumentType (LONG *pDocType);
HRESULT GetFollowingPunct(LPWSTR *plpstrFollowingPunct);
HRESULT SetFollowingPunct(LPWSTR lpstrFollowingPunct);
HRESULT GetLeadingPunct (LPWSTR *plpstrLeadingPunct);
HRESULT SetLeadingPunct (LPWSTR lpstrLeadingPunct);
HRESULT GetViewKind (long *pValue);
HRESULT SetViewKind (long Value);
HRESULT GetViewScale (long *pValue);
HRESULT SetViewScale (long Value);
// Notification Management Methods. In principle, these methods
// could form a separate class, but for space savings, they are part
// of the CTxtEdit class
HRESULT TxNotify(DWORD iNotify, void *pv); //@cmember General-purpose
// notification
void SendScrollEvent(DWORD iNotify); //@cmember Send scroll
// event
void SendUpdateEvent(); //@cmember Send EN_UPDATE
// event
//@cmember Use EN_PROTECTED
BOOL QueryUseProtection( CTxtRange *prg, // to query protection
UINT msg,WPARAM wparam, LPARAM lparam);// usage
//@cmember indicates whether
// or not protection checking
// enabled
BOOL IsProtectionCheckingEnabled()
{ return !!(_dwEventMask & ENM_PROTECTED); }
// FUTURE (alexgo): maybe we can use just one method :-)
BOOL IsntProtectedOrReadOnly(UINT msg, WPARAM wparam, LPARAM lparam);
BOOL IsProtected(UINT msg, WPARAM wparam, LPARAM lparam);
BOOL IsProtectedRange(UINT msg, WPARAM wparam, LPARAM lparam, CTxtRange *prg);
DWORD GetEventMask(){return _dwEventMask;}//@cmember Get event mask
void SetStreaming(BOOL flag)
{ _fStreaming = flag; }
BOOL IsStreaming() { return _fStreaming; }
//@cmember Handles EN_LINK
// notifications.
BOOL HandleLinkNotification(UINT msg, WPARAM wparam, LPARAM lparam,
BOOL *pfInLink = NULL);
HRESULT CloseFile (BOOL bSave);
//--------------------------------------------------------------
// Inline proxies to ITextHost methods
//--------------------------------------------------------------
// Persisted properties (persisted by the host)
// Get methods: called by the Text Services component to get
// the value of a given persisted property
// FUTURE (alexgo) !! some of these need to get cleaned up
BOOL TxGetAutoSize() const;
BOOL TxGetAutoWordSel() const;
COLORREF TxGetBackColor() const {return _phost->TxGetSysColor(COLOR_WINDOW);}
TXTBACKSTYLE TxGetBackStyle() const;
HRESULT TxGetDefaultCharFormat(CCharFormat *pCF);
void TxGetClientRect(LPRECT prc) const {_phost->TxGetClientRect(prc);}
HRESULT TxGetExtent(SIZEL *psizelExtents)
{return _phost->TxGetExtent(psizelExtents);}
COLORREF TxGetForeColor() const {return _phost->TxGetSysColor(COLOR_WINDOWTEXT);}
DWORD TxGetMaxLength() const;
void TxSetMaxToMaxText();
BOOL TxGetModified() const {return _fModified;}
BOOL TxGetMultiLine() const;
HRESULT TxGetDefaultParaFormat(CParaFormat *pPF);
TCHAR TxGetPasswordChar() const;
BOOL TxGetReadOnly() const {return _fReadOnly;}
BOOL TxGetSaveSelection() const;
DWORD TxGetScrollBars() const ;
BOOL TxGetSelectionBar() const;
// LONG TxGetSelectionBarWidth() const;
void TxGetViewInset(LPRECT prc, CDisplay *pdp) const;
BOOL TxGetWordWrap() const;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?