00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined(AFX_RICHVIEWCTRL_H__EB7BD9A6_8F32_48F1_ACAA_3503B8A61769__INCLUDED_)
00023 #define AFX_RICHVIEWCTRL_H__EB7BD9A6_8F32_48F1_ACAA_3503B8A61769__INCLUDED_
00024
00025 #pragma once
00026
00027 class CRichDocument;
00028 class CRichElement;
00029 class CRichFragment;
00030
00031 typedef struct
00032 {
00033 int nFragment;
00034 int nOffset;
00035 } RICHPOSITION;
00036
00037
00038 class CRichViewCtrl : public CWnd
00039 {
00040
00041 public:
00042 CRichViewCtrl();
00043 virtual ~CRichViewCtrl();
00044
00045
00046 protected:
00047 CSyncObject* m_pSyncRoot;
00048 BOOL m_bSelectable;
00049 BOOL m_bFollowBottom;
00050 BOOL m_bDefaultLink;
00051 protected:
00052 CRichDocument* m_pDocument;
00053 DWORD m_nCookie;
00054 CPtrArray m_pFragments;
00055 int m_nLength;
00056 int m_nScrollWheelLines;
00057 protected:
00058 CRichElement* m_pHover;
00059 BOOL m_bSelecting;
00060 RICHPOSITION m_pSelStart;
00061 RICHPOSITION m_pSelEnd;
00062 RICHPOSITION m_pSelAbsStart;
00063 RICHPOSITION m_pSelAbsEnd;
00064 protected:
00065 HCURSOR m_hcHand;
00066 HCURSOR m_hcText;
00067 CBrush m_pBrush;
00068
00069
00070 public:
00071 void SetSyncObject(CSyncObject* pSyncRoot);
00072 void SetSelectable(BOOL bSelectable);
00073 void SetFollowBottom(BOOL bFollowBottom);
00074 void SetDefaultLink(BOOL bDefaultLink);
00075 void SetDocument(CRichDocument* pDocument);
00076 BOOL IsModified() const;
00077 void InvalidateIfModified();
00078 int FullHeightMove(int nX, int nY, int nWidth, BOOL bShow = FALSE);
00079 BOOL GetElementRect(CRichElement* pElement, RECT* prc);
00080 protected:
00081 void ClearFragments();
00082 void Layout(CDC* pDC, CRect* pRect);
00083 void WrapLineHelper(CPtrList& pLine, CPoint& pt, int& nLineHeight, int nWidth, int nAlign);
00084 CRichFragment* PointToFrag(CPoint& pt);
00085 RICHPOSITION PointToPosition(CPoint& pt);
00086 CPoint PositionToPoint(RICHPOSITION& pt);
00087 void UpdateSelection();
00088 void CopySelection();
00089 protected:
00090 virtual void OnLayoutComplete() {};
00091 virtual void OnPaintBegin(CDC* pDC) {};
00092 virtual void OnPaintComplete(CDC* pDC) {};
00093 virtual void OnVScrolled() {};
00094
00095
00096 public:
00097
00098 public:
00099 virtual BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
00100
00101
00102
00103 protected:
00104
00105 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
00106 afx_msg void OnDestroy();
00107 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
00108 afx_msg void OnPaint();
00109 afx_msg void OnSize(UINT nType, int cx, int cy);
00110 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
00111 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
00112 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
00113 afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
00114 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
00115 afx_msg void OnTimer(UINT nIDEvent);
00116 afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
00117
00118 DECLARE_MESSAGE_MAP()
00119
00120 friend class CRichFragment;
00121 };
00122
00123 typedef struct
00124 {
00125 NMHDR hdr;
00126 CRichElement* pElement;
00127 } RVN_ELEMENTEVENT;
00128
00129 #define RVN_CLICK 100
00130
00131
00132
00133 #endif // !defined(AFX_RICHVIEWCTRL_H__EB7BD9A6_8F32_48F1_ACAA_3503B8A61769__INCLUDED_)