merge to XFA: Fix -Wnon-virtual-dtor compiler warnings.
[pdfium.git] / fpdfsdk / include / pdfwindow / PWL_Edit.h
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4  
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #ifndef _PWL_EDIT_H_
8 #define _PWL_EDIT_H_
9
10 class IPWL_Filler_Notify;
11 class CPWL_Edit;
12 class IPWL_SpellCheck;
13
14 class IPWL_Filler_Notify
15 {
16 public:
17         virtual ~IPWL_Filler_Notify() { }
18         virtual void                                    QueryWherePopup(void* pPrivateData, FX_FLOAT fPopupMin,FX_FLOAT fPopupMax, 
19                                                                                 FX_INT32 & nRet, FX_FLOAT & fPopupRet) = 0; //nRet: (0:bottom 1:top)
20         virtual void                                    OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_INT32 nKeyCode,
21                                                                                 CFX_WideString & strChange, const CFX_WideString& strChangeEx, 
22                                                                                 int nSelStart, int nSelEnd,
23                                                                                 FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit, FX_DWORD nFlag) = 0;
24         virtual void                                    OnAfterKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_BOOL & bExit, FX_DWORD nFlag) = 0;
25
26         virtual void                                    OnPopupPreOpen(void* pPrivateData, FX_BOOL& bExit, FX_DWORD nFlag) = 0;
27         virtual void                                    OnPopupPostOpen(void* pPrivateData, FX_BOOL& bExit, FX_DWORD nFlag) = 0;
28 };
29
30 class PWL_CLASS CPWL_Edit : public CPWL_EditCtrl, public IFX_Edit_OprNotify
31 {
32 public:
33         CPWL_Edit();
34         virtual ~CPWL_Edit();
35
36 public:
37         virtual CFX_ByteString                  GetClassName() const;
38         virtual void                                    OnDestroy();
39         virtual void                                    OnCreated();
40         virtual void                                    RePosChildWnd();
41         virtual CPDF_Rect                               GetClientRect() const;
42
43         virtual void                                    GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream);
44         virtual void                                    DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device);
45
46         virtual FX_BOOL                                 OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag);
47         virtual FX_BOOL                                 OnLButtonDblClk(const CPDF_Point & point, FX_DWORD nFlag);
48         virtual FX_BOOL                                 OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag);
49         virtual FX_BOOL                                 OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag);
50
51         virtual FX_BOOL                                 OnKeyDown(FX_WORD nChar, FX_DWORD nFlag);
52         virtual FX_BOOL                                 OnChar(FX_WORD nChar, FX_DWORD nFlag);
53
54         virtual CPDF_Rect                               GetFocusRect() const;
55
56 public:         
57         void                                                    SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat = PEAH_LEFT, FX_BOOL bPaint = TRUE);     //0:left 1:right 2:middle 
58         void                                                    SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat = PEAV_TOP, FX_BOOL bPaint = TRUE);      //0:top 1:bottom 2:center
59
60         void                                                    SetCharArray(FX_INT32 nCharArray);
61         void                                                    SetLimitChar(FX_INT32 nLimitChar);
62
63         void                                                    SetHorzScale(FX_INT32 nHorzScale, FX_BOOL bPaint = TRUE);
64         void                                                    SetCharSpace(FX_FLOAT fCharSpace, FX_BOOL bPaint = TRUE);
65
66         void                                                    SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint = TRUE);
67
68         void                                                    EnableSpellCheck(FX_BOOL bEnabled);
69
70         FX_BOOL                                                 CanSelectAll() const;
71         FX_BOOL                                                 CanClear() const;
72         FX_BOOL                                                 CanCopy() const;
73         FX_BOOL                                                 CanCut() const;
74         FX_BOOL                                                 CanPaste() const;
75
76         virtual void                                    CopyText();
77         virtual void                                    PasteText();
78         virtual void                                    CutText();
79
80         virtual void                                    SetText(FX_LPCWSTR csText);
81         void                                                    ReplaceSel(FX_LPCWSTR csText);
82
83         CFX_ByteString                                  GetTextAppearanceStream(const CPDF_Point & ptOffset) const;
84         CFX_ByteString                                  GetCaretAppearanceStream(const CPDF_Point & ptOffset) const;    
85         CFX_ByteString                                  GetSelectAppearanceStream(const CPDF_Point & ptOffset) const;
86
87         FX_BOOL                                                 IsTextFull() const;     
88
89         static FX_FLOAT                                 GetCharArrayAutoFontSize(CPDF_Font* pFont, const CPDF_Rect& rcPlate, FX_INT32 nCharArray);
90
91         void                                                    SetFillerNotify(IPWL_Filler_Notify* pNotify) {m_pFillerNotify = pNotify;}
92
93         void                                                    GeneratePageObjects(CPDF_PageObjects* pPageObjects, 
94                                                                                 const CPDF_Point& ptOffset, CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray);
95         void                                                    GeneratePageObjects(CPDF_PageObjects* pPageObjects, 
96                                                                                 const CPDF_Point& ptOffset);
97
98 protected:
99         virtual void                                    OnSetFocus();
100         virtual void                                    OnKillFocus();
101
102 protected:
103         virtual void                                    OnInsertWord(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace);
104         virtual void                                    OnInsertReturn(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace);
105         virtual void                                    OnBackSpace(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace);
106         virtual void                                    OnDelete(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace);
107         virtual void                                    OnClear(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace);
108         virtual void                                    OnSetText(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace);
109         virtual void                                    OnInsertText(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace);
110         virtual void                                    OnAddUndo(IFX_Edit_UndoItem* pUndoItem);
111
112 private:        
113         CPVT_WordRange                                  GetSelectWordRange() const;
114         virtual void                                    ShowVScrollBar(FX_BOOL bShow);
115         FX_BOOL                                                 IsVScrollBarVisible() const;
116         void                                                    SetParamByFlag();
117
118         FX_FLOAT                                                GetCharArrayAutoFontSize(FX_INT32 nCharArray);
119         CPDF_Point                                              GetWordRightBottomPoint(const CPVT_WordPlace& wpWord);
120
121         CPVT_WordRange                                  CombineWordRange(const CPVT_WordRange& wr1, const CPVT_WordRange& wr2);
122         CPVT_WordRange                                  GetLatinWordsRange(const CPDF_Point & point) const;
123         CPVT_WordRange                                  GetLatinWordsRange(const CPVT_WordPlace & place) const;
124         CPVT_WordRange                                  GetArabicWordsRange(const CPVT_WordPlace & place) const;
125         CPVT_WordRange                                  GetSameWordsRange(const CPVT_WordPlace & place, FX_BOOL bLatin, FX_BOOL bArabic) const;
126
127         void                                                    AjustArabicWords(const CPVT_WordRange& wr);
128 public:
129         FX_BOOL                                                 IsProceedtoOnChar(FX_WORD nKeyCode, FX_DWORD nFlag);
130 private:
131         IPWL_Filler_Notify*                             m_pFillerNotify;
132         IPWL_SpellCheck*                                m_pSpellCheck;
133         FX_BOOL                                                 m_bFocus;
134         CPDF_Rect                                               m_rcOldWindow;
135 public:
136         void                                                    AttachFFLData(void* pData) {m_pFormFiller = pData;}
137 private:
138         void*                                                   m_pFormFiller;
139 };
140
141 #endif 
142