OLD | NEW |
| (Empty) |
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 XFA_FWL_BASEWIDGET_IFWL_EDIT_H_ | |
8 #define XFA_FWL_BASEWIDGET_IFWL_EDIT_H_ | |
9 | |
10 #include <vector> | |
11 | |
12 #include "xfa/fwl/core/cfwl_event.h" | |
13 #include "xfa/fwl/core/ifwl_dataprovider.h" | |
14 #include "xfa/fwl/lightwidget/cfwl_widget.h" | |
15 | |
16 #define FWL_CLASS_Edit L"FWL_EDIT" | |
17 #define FWL_STYLEEXT_EDT_ReadOnly (1L << 0) | |
18 #define FWL_STYLEEXT_EDT_MultiLine (1L << 1) | |
19 #define FWL_STYLEEXT_EDT_WantReturn (1L << 2) | |
20 #define FWL_STYLEEXT_EDT_NoHideSel (1L << 3) | |
21 #define FWL_STYLEEXT_EDT_AutoHScroll (1L << 4) | |
22 #define FWL_STYLEEXT_EDT_AutoVScroll (1L << 5) | |
23 #define FWL_STYLEEXT_EDT_NoRedoUndo (1L << 6) | |
24 #define FWL_STYLEEXT_EDT_Validate (1L << 7) | |
25 #define FWL_STYLEEXT_EDT_Password (1L << 8) | |
26 #define FWL_STYLEEXT_EDT_Number (1L << 9) | |
27 #define FWL_STYLEEXT_EDT_HSelfAdaption (1L << 10) | |
28 #define FWL_STYLEEXT_EDT_VSelfAdaption (1L << 11) | |
29 #define FWL_STYLEEXT_EDT_VerticalLayout (1L << 12) | |
30 #define FWL_STYLEEXT_EDT_VerticalChars (1L << 13) | |
31 #define FWL_STYLEEXT_EDT_ReverseLine (1L << 14) | |
32 #define FWL_STYLEEXT_EDT_ArabicShapes (1L << 15) | |
33 #define FWL_STYLEEXT_EDT_ExpandTab (1L << 16) | |
34 #define FWL_STYLEEXT_EDT_CombText (1L << 17) | |
35 #define FWL_STYLEEXT_EDT_HNear (0L << 18) | |
36 #define FWL_STYLEEXT_EDT_HCenter (1L << 18) | |
37 #define FWL_STYLEEXT_EDT_HFar (2L << 18) | |
38 #define FWL_STYLEEXT_EDT_VNear (0L << 20) | |
39 #define FWL_STYLEEXT_EDT_VCenter (1L << 20) | |
40 #define FWL_STYLEEXT_EDT_VFar (2L << 20) | |
41 #define FWL_STYLEEXT_EDT_Justified (1L << 22) | |
42 #define FWL_STYLEEXT_EDT_Distributed (2L << 22) | |
43 #define FWL_STYLEEXT_EDT_HAlignMask (3L << 18) | |
44 #define FWL_STYLEEXT_EDT_VAlignMask (3L << 20) | |
45 #define FWL_STYLEEXT_EDT_HAlignModeMask (3L << 22) | |
46 #define FWL_STYLEEXT_EDT_InnerCaret (1L << 24) | |
47 #define FWL_STYLEEXT_EDT_ShowScrollbarFocus (1L << 25) | |
48 #define FWL_STYLEEXT_EDT_OuterScrollbar (1L << 26) | |
49 #define FWL_STYLEEXT_EDT_LastLineHeight (1L << 27) | |
50 | |
51 enum FWL_EDT_TEXTCHANGED { | |
52 FWL_EDT_TEXTCHANGED_Insert = 0, | |
53 FWL_EDT_TEXTCHANGED_Delete, | |
54 FWL_EDT_TEXTCHANGED_Replace, | |
55 }; | |
56 | |
57 FWL_EVENT_DEF(CFWL_EvtEdtTextChanged, | |
58 CFWL_EventType::TextChanged, | |
59 int32_t nChangeType; | |
60 CFX_WideString wsInsert; | |
61 CFX_WideString wsDelete; | |
62 CFX_WideString wsPrevText;) | |
63 | |
64 FWL_EVENT_DEF(CFWL_EvtEdtTextFull, CFWL_EventType::TextFull) | |
65 | |
66 FWL_EVENT_DEF(CFWL_EvtEdtPreSelfAdaption, | |
67 CFWL_EventType::PreSelfAdaption, | |
68 FX_BOOL bHSelfAdaption; | |
69 FX_BOOL bVSelfAdaption; | |
70 CFX_RectF rtAfterChange;) | |
71 | |
72 FWL_EVENT_DEF(CFWL_EvtEdtValidate, | |
73 CFWL_EventType::Validate, | |
74 IFWL_Widget* pDstWidget; | |
75 CFX_WideString wsInsert; | |
76 FX_BOOL bValidate;) | |
77 | |
78 FWL_EVENT_DEF(CFWL_EvtEdtCheckWord, | |
79 CFWL_EventType::CheckWord, | |
80 CFX_ByteString bsWord; | |
81 FX_BOOL bCheckWord;) | |
82 | |
83 FWL_EVENT_DEF(CFWL_EvtEdtGetSuggestWords, | |
84 CFWL_EventType::GetSuggestedWords, | |
85 FX_BOOL bSuggestWords; | |
86 CFX_ByteString bsWord; | |
87 std::vector<CFX_ByteString> bsArraySuggestWords;) | |
88 | |
89 class CFWL_WidgetImpProperties; | |
90 class IFDE_TxtEdtDoRecord; | |
91 | |
92 class IFWL_EditDP : public IFWL_DataProvider {}; | |
93 | |
94 class IFWL_Edit : public IFWL_Widget { | |
95 public: | |
96 static IFWL_Edit* Create(const CFWL_WidgetImpProperties& properties, | |
97 IFWL_Widget* pOuter); | |
98 static IFWL_Edit* CreateComboEdit(const CFWL_WidgetImpProperties& properties, | |
99 IFWL_Widget* pOuter); | |
100 | |
101 FWL_Error SetText(const CFX_WideString& wsText); | |
102 int32_t GetTextLength() const; | |
103 FWL_Error GetText(CFX_WideString& wsText, | |
104 int32_t nStart = 0, | |
105 int32_t nCount = -1) const; | |
106 FWL_Error ClearText(); | |
107 int32_t GetCaretPos() const; | |
108 int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore = TRUE); | |
109 FWL_Error AddSelRange(int32_t nStart, int32_t nCount = -1); | |
110 int32_t CountSelRanges(); | |
111 int32_t GetSelRange(int32_t nIndex, int32_t& nStart); | |
112 FWL_Error ClearSelections(); | |
113 int32_t GetLimit(); | |
114 FWL_Error SetLimit(int32_t nLimit); | |
115 FWL_Error SetAliasChar(FX_WCHAR wAlias); | |
116 FWL_Error Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLen); | |
117 FWL_Error DeleteSelections(); | |
118 FWL_Error DeleteRange(int32_t nStart, int32_t nCount = -1); | |
119 FWL_Error Replace(int32_t nStart, | |
120 int32_t nLen, | |
121 const CFX_WideStringC& wsReplace); | |
122 FWL_Error DoClipboard(int32_t iCmd); | |
123 FX_BOOL Copy(CFX_WideString& wsCopy); | |
124 FX_BOOL Cut(CFX_WideString& wsCut); | |
125 FX_BOOL Paste(const CFX_WideString& wsPaste); | |
126 FX_BOOL Delete(); | |
127 FX_BOOL Redo(const IFDE_TxtEdtDoRecord* pRecord); | |
128 FX_BOOL Undo(const IFDE_TxtEdtDoRecord* pRecord); | |
129 FX_BOOL Undo(); | |
130 FX_BOOL Redo(); | |
131 FX_BOOL CanUndo(); | |
132 FX_BOOL CanRedo(); | |
133 FWL_Error SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant); | |
134 FWL_Error SetOuter(IFWL_Widget* pOuter); | |
135 FWL_Error SetNumberRange(int32_t iMin, int32_t iMax); | |
136 FWL_Error SetBackColor(uint32_t dwColor); | |
137 FWL_Error SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize); | |
138 void SetScrollOffset(FX_FLOAT fScrollOffset); | |
139 FX_BOOL GetSuggestWords(CFX_PointF pointf, | |
140 std::vector<CFX_ByteString>& sSuggest); | |
141 FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, | |
142 const CFX_ByteStringC& bsReplace); | |
143 | |
144 protected: | |
145 IFWL_Edit(); | |
146 }; | |
147 | |
148 #endif // XFA_FWL_BASEWIDGET_IFWL_EDIT_H_ | |
OLD | NEW |