Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: xfa/fwl/lightwidget/cfwl_edit.cpp

Issue 1834323003: Move xfa/include/fwl/{theme,lightwidget} to xfa/fwl (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/include/fwl/lightwidget/edit.h" 7 #include "xfa/fwl/lightwidget/cfwl_edit.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
11 11
12 #include "xfa/fwl/basewidget/ifwl_edit.h" 12 #include "xfa/fwl/basewidget/ifwl_edit.h"
13 13
14 CFWL_Edit* CFWL_Edit::Create() { 14 CFWL_Edit* CFWL_Edit::Create() {
15 return new CFWL_Edit; 15 return new CFWL_Edit;
16 } 16 }
17
17 FWL_ERR CFWL_Edit::Initialize(const CFWL_WidgetProperties* pProperties) { 18 FWL_ERR CFWL_Edit::Initialize(const CFWL_WidgetProperties* pProperties) {
18 if (m_pIface) 19 if (m_pIface)
19 return FWL_ERR_Indefinite; 20 return FWL_ERR_Indefinite;
20 if (pProperties) { 21 if (pProperties) {
21 *m_pProperties = *pProperties; 22 *m_pProperties = *pProperties;
22 } 23 }
23 std::unique_ptr<IFWL_Edit> pEdit(IFWL_Edit::Create( 24 std::unique_ptr<IFWL_Edit> pEdit(IFWL_Edit::Create(
24 m_pProperties->MakeWidgetImpProperties(nullptr), nullptr)); 25 m_pProperties->MakeWidgetImpProperties(nullptr), nullptr));
25 FWL_ERR ret = pEdit->Initialize(); 26 FWL_ERR ret = pEdit->Initialize();
26 if (ret != FWL_ERR_Succeeded) { 27 if (ret != FWL_ERR_Succeeded) {
27 return ret; 28 return ret;
28 } 29 }
29 m_pIface = pEdit.release(); 30 m_pIface = pEdit.release();
30 CFWL_Widget::Initialize(); 31 CFWL_Widget::Initialize();
31 return FWL_ERR_Succeeded; 32 return FWL_ERR_Succeeded;
32 } 33 }
34
33 FWL_ERR CFWL_Edit::SetText(const CFX_WideString& wsText) { 35 FWL_ERR CFWL_Edit::SetText(const CFX_WideString& wsText) {
34 if (!m_pIface) 36 if (!m_pIface)
35 return FWL_ERR_Indefinite; 37 return FWL_ERR_Indefinite;
36 return static_cast<IFWL_Edit*>(m_pIface)->SetText(wsText); 38 return static_cast<IFWL_Edit*>(m_pIface)->SetText(wsText);
37 } 39 }
40
38 int32_t CFWL_Edit::GetTextLength() const { 41 int32_t CFWL_Edit::GetTextLength() const {
39 if (!m_pIface) 42 if (!m_pIface)
40 return 0; 43 return 0;
41 return static_cast<IFWL_Edit*>(m_pIface)->GetTextLength(); 44 return static_cast<IFWL_Edit*>(m_pIface)->GetTextLength();
42 } 45 }
46
43 FWL_ERR CFWL_Edit::GetText(CFX_WideString& wsText, 47 FWL_ERR CFWL_Edit::GetText(CFX_WideString& wsText,
44 int32_t nStart, 48 int32_t nStart,
45 int32_t nCount) const { 49 int32_t nCount) const {
46 if (!m_pIface) 50 if (!m_pIface)
47 return FWL_ERR_Indefinite; 51 return FWL_ERR_Indefinite;
48 return static_cast<IFWL_Edit*>(m_pIface)->GetText(wsText, nStart, nCount); 52 return static_cast<IFWL_Edit*>(m_pIface)->GetText(wsText, nStart, nCount);
49 } 53 }
54
50 FWL_ERR CFWL_Edit::ClearText() { 55 FWL_ERR CFWL_Edit::ClearText() {
51 if (!m_pIface) 56 if (!m_pIface)
52 return FWL_ERR_Indefinite; 57 return FWL_ERR_Indefinite;
53 return static_cast<IFWL_Edit*>(m_pIface)->ClearText(); 58 return static_cast<IFWL_Edit*>(m_pIface)->ClearText();
54 } 59 }
60
55 int32_t CFWL_Edit::GetCaretPos() const { 61 int32_t CFWL_Edit::GetCaretPos() const {
56 if (!m_pIface) 62 if (!m_pIface)
57 return -1; 63 return -1;
58 return static_cast<IFWL_Edit*>(m_pIface)->GetCaretPos(); 64 return static_cast<IFWL_Edit*>(m_pIface)->GetCaretPos();
59 } 65 }
66
60 int32_t CFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { 67 int32_t CFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) {
61 if (!m_pIface) 68 if (!m_pIface)
62 return -1; 69 return -1;
63 return static_cast<IFWL_Edit*>(m_pIface)->SetCaretPos(nIndex, bBefore); 70 return static_cast<IFWL_Edit*>(m_pIface)->SetCaretPos(nIndex, bBefore);
64 } 71 }
72
65 FWL_ERR CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { 73 FWL_ERR CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) {
66 if (!m_pIface) 74 if (!m_pIface)
67 return FWL_ERR_Indefinite; 75 return FWL_ERR_Indefinite;
68 static_cast<IFWL_Edit*>(m_pIface)->AddSelRange(nStart, nCount); 76 static_cast<IFWL_Edit*>(m_pIface)->AddSelRange(nStart, nCount);
69 int32_t pos = 0; 77 int32_t pos = 0;
70 int32_t sum = static_cast<IFWL_Edit*>(m_pIface)->GetTextLength(); 78 int32_t sum = static_cast<IFWL_Edit*>(m_pIface)->GetTextLength();
71 if (nCount == -1) { 79 if (nCount == -1) {
72 pos = sum; 80 pos = sum;
73 } else { 81 } else {
74 pos = nStart + nCount; 82 pos = nStart + nCount;
75 } 83 }
76 return static_cast<IFWL_Edit*>(m_pIface)->SetCaretPos(pos); 84 return static_cast<IFWL_Edit*>(m_pIface)->SetCaretPos(pos);
77 } 85 }
86
78 int32_t CFWL_Edit::CountSelRanges() { 87 int32_t CFWL_Edit::CountSelRanges() {
79 if (!m_pIface) 88 if (!m_pIface)
80 return 0; 89 return 0;
81 return static_cast<IFWL_Edit*>(m_pIface)->CountSelRanges(); 90 return static_cast<IFWL_Edit*>(m_pIface)->CountSelRanges();
82 } 91 }
92
83 int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { 93 int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) {
84 if (!m_pIface) 94 if (!m_pIface)
85 return 0; 95 return 0;
86 return static_cast<IFWL_Edit*>(m_pIface)->GetSelRange(nIndex, nStart); 96 return static_cast<IFWL_Edit*>(m_pIface)->GetSelRange(nIndex, nStart);
87 } 97 }
98
88 FWL_ERR CFWL_Edit::ClearSelections() { 99 FWL_ERR CFWL_Edit::ClearSelections() {
89 if (!m_pIface) 100 if (!m_pIface)
90 return FWL_ERR_Indefinite; 101 return FWL_ERR_Indefinite;
91 return static_cast<IFWL_Edit*>(m_pIface)->ClearSelections(); 102 return static_cast<IFWL_Edit*>(m_pIface)->ClearSelections();
92 } 103 }
104
93 int32_t CFWL_Edit::GetLimit() { 105 int32_t CFWL_Edit::GetLimit() {
94 if (!m_pIface) 106 if (!m_pIface)
95 return -1; 107 return -1;
96 return static_cast<IFWL_Edit*>(m_pIface)->GetLimit(); 108 return static_cast<IFWL_Edit*>(m_pIface)->GetLimit();
97 } 109 }
110
98 FWL_ERR CFWL_Edit::SetLimit(int32_t nLimit) { 111 FWL_ERR CFWL_Edit::SetLimit(int32_t nLimit) {
99 if (!m_pIface) 112 if (!m_pIface)
100 return FWL_ERR_Indefinite; 113 return FWL_ERR_Indefinite;
101 return static_cast<IFWL_Edit*>(m_pIface)->SetLimit(nLimit); 114 return static_cast<IFWL_Edit*>(m_pIface)->SetLimit(nLimit);
102 } 115 }
116
103 FWL_ERR CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { 117 FWL_ERR CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) {
104 if (!m_pIface) 118 if (!m_pIface)
105 return FWL_ERR_Indefinite; 119 return FWL_ERR_Indefinite;
106 return static_cast<IFWL_Edit*>(m_pIface)->SetAliasChar(wAlias); 120 return static_cast<IFWL_Edit*>(m_pIface)->SetAliasChar(wAlias);
107 } 121 }
122
108 FWL_ERR CFWL_Edit::Insert(int32_t nStart, 123 FWL_ERR CFWL_Edit::Insert(int32_t nStart,
109 const FX_WCHAR* lpText, 124 const FX_WCHAR* lpText,
110 int32_t nLen) { 125 int32_t nLen) {
111 if (!m_pIface) 126 if (!m_pIface)
112 return FWL_ERR_Indefinite; 127 return FWL_ERR_Indefinite;
113 return static_cast<IFWL_Edit*>(m_pIface)->Insert(nStart, lpText, nLen); 128 return static_cast<IFWL_Edit*>(m_pIface)->Insert(nStart, lpText, nLen);
114 } 129 }
130
115 FWL_ERR CFWL_Edit::DeleteSelections() { 131 FWL_ERR CFWL_Edit::DeleteSelections() {
116 if (!m_pIface) 132 if (!m_pIface)
117 return FWL_ERR_Indefinite; 133 return FWL_ERR_Indefinite;
118 return static_cast<IFWL_Edit*>(m_pIface)->DeleteSelections(); 134 return static_cast<IFWL_Edit*>(m_pIface)->DeleteSelections();
119 } 135 }
136
120 FWL_ERR CFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) { 137 FWL_ERR CFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) {
121 if (!m_pIface) 138 if (!m_pIface)
122 return FWL_ERR_Indefinite; 139 return FWL_ERR_Indefinite;
123 return static_cast<IFWL_Edit*>(m_pIface)->DeleteRange(nStart, nCount); 140 return static_cast<IFWL_Edit*>(m_pIface)->DeleteRange(nStart, nCount);
124 } 141 }
142
125 FWL_ERR CFWL_Edit::ReplaceSelections(const CFX_WideStringC& wsReplace) { 143 FWL_ERR CFWL_Edit::ReplaceSelections(const CFX_WideStringC& wsReplace) {
126 if (!m_pIface) 144 if (!m_pIface)
127 return FWL_ERR_Indefinite; 145 return FWL_ERR_Indefinite;
128 return static_cast<IFWL_Edit*>(m_pIface)->ReplaceSelections(wsReplace); 146 return static_cast<IFWL_Edit*>(m_pIface)->ReplaceSelections(wsReplace);
129 } 147 }
148
130 FWL_ERR CFWL_Edit::Replace(int32_t nStart, 149 FWL_ERR CFWL_Edit::Replace(int32_t nStart,
131 int32_t nLen, 150 int32_t nLen,
132 const CFX_WideStringC& wsReplace) { 151 const CFX_WideStringC& wsReplace) {
133 if (!m_pIface) 152 if (!m_pIface)
134 return FWL_ERR_Indefinite; 153 return FWL_ERR_Indefinite;
135 return static_cast<IFWL_Edit*>(m_pIface)->Replace(nStart, nLen, wsReplace); 154 return static_cast<IFWL_Edit*>(m_pIface)->Replace(nStart, nLen, wsReplace);
136 } 155 }
156
137 FWL_ERR CFWL_Edit::DoClipboard(int32_t iCmd) { 157 FWL_ERR CFWL_Edit::DoClipboard(int32_t iCmd) {
138 if (!m_pIface) 158 if (!m_pIface)
139 return FWL_ERR_Indefinite; 159 return FWL_ERR_Indefinite;
140 return static_cast<IFWL_Edit*>(m_pIface)->DoClipboard(iCmd); 160 return static_cast<IFWL_Edit*>(m_pIface)->DoClipboard(iCmd);
141 } 161 }
162
142 FX_BOOL CFWL_Edit::Redo(const CFX_ByteStringC& bsRecord) { 163 FX_BOOL CFWL_Edit::Redo(const CFX_ByteStringC& bsRecord) {
143 if (!m_pIface) 164 if (!m_pIface)
144 return FALSE; 165 return FALSE;
145 return static_cast<IFWL_Edit*>(m_pIface)->Redo(bsRecord); 166 return static_cast<IFWL_Edit*>(m_pIface)->Redo(bsRecord);
146 } 167 }
168
147 FX_BOOL CFWL_Edit::Undo(const CFX_ByteStringC& bsRecord) { 169 FX_BOOL CFWL_Edit::Undo(const CFX_ByteStringC& bsRecord) {
148 if (!m_pIface) 170 if (!m_pIface)
149 return FALSE; 171 return FALSE;
150 return static_cast<IFWL_Edit*>(m_pIface)->Undo(bsRecord); 172 return static_cast<IFWL_Edit*>(m_pIface)->Undo(bsRecord);
151 } 173 }
174
152 FWL_ERR CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { 175 FWL_ERR CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
153 if (!m_pIface) 176 if (!m_pIface)
154 return FWL_ERR_Indefinite; 177 return FWL_ERR_Indefinite;
155 return static_cast<IFWL_Edit*>(m_pIface) 178 return static_cast<IFWL_Edit*>(m_pIface)
156 ->SetTabWidth(fTabWidth, bEquidistant); 179 ->SetTabWidth(fTabWidth, bEquidistant);
157 } 180 }
181
158 FWL_ERR CFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { 182 FWL_ERR CFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) {
159 if (iMin > iMax) { 183 if (iMin > iMax) {
160 return FWL_ERR_Parameter_Invalid; 184 return FWL_ERR_Parameter_Invalid;
161 } 185 }
162 return static_cast<IFWL_Edit*>(m_pIface)->SetNumberRange(iMin, iMax); 186 return static_cast<IFWL_Edit*>(m_pIface)->SetNumberRange(iMin, iMax);
163 } 187 }
188
164 FWL_ERR CFWL_Edit::SetBackColor(uint32_t dwColor) { 189 FWL_ERR CFWL_Edit::SetBackColor(uint32_t dwColor) {
165 if (!m_pIface) 190 if (!m_pIface)
166 return FWL_ERR_Indefinite; 191 return FWL_ERR_Indefinite;
167 return static_cast<IFWL_Edit*>(m_pIface)->SetBackColor(dwColor); 192 return static_cast<IFWL_Edit*>(m_pIface)->SetBackColor(dwColor);
168 } 193 }
194
169 FWL_ERR CFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { 195 FWL_ERR CFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) {
170 if (!m_pIface) 196 if (!m_pIface)
171 return FWL_ERR_Indefinite; 197 return FWL_ERR_Indefinite;
172 return static_cast<IFWL_Edit*>(m_pIface)->SetFont(wsFont, fSize); 198 return static_cast<IFWL_Edit*>(m_pIface)->SetFont(wsFont, fSize);
173 } 199 }
200
174 FX_BOOL CFWL_Edit::CanUndo() { 201 FX_BOOL CFWL_Edit::CanUndo() {
175 return static_cast<IFWL_Edit*>(m_pIface)->CanUndo(); 202 return static_cast<IFWL_Edit*>(m_pIface)->CanUndo();
176 } 203 }
204
177 FX_BOOL CFWL_Edit::CanRedo() { 205 FX_BOOL CFWL_Edit::CanRedo() {
178 return static_cast<IFWL_Edit*>(m_pIface)->CanRedo(); 206 return static_cast<IFWL_Edit*>(m_pIface)->CanRedo();
179 } 207 }
208
180 FX_BOOL CFWL_Edit::Undo() { 209 FX_BOOL CFWL_Edit::Undo() {
181 return static_cast<IFWL_Edit*>(m_pIface)->Undo(); 210 return static_cast<IFWL_Edit*>(m_pIface)->Undo();
182 } 211 }
212
183 FX_BOOL CFWL_Edit::Redo() { 213 FX_BOOL CFWL_Edit::Redo() {
184 return static_cast<IFWL_Edit*>(m_pIface)->Undo(); 214 return static_cast<IFWL_Edit*>(m_pIface)->Undo();
185 } 215 }
216
186 FX_BOOL CFWL_Edit::Copy(CFX_WideString& wsCopy) { 217 FX_BOOL CFWL_Edit::Copy(CFX_WideString& wsCopy) {
187 return static_cast<IFWL_Edit*>(m_pIface)->Copy(wsCopy); 218 return static_cast<IFWL_Edit*>(m_pIface)->Copy(wsCopy);
188 } 219 }
220
189 FX_BOOL CFWL_Edit::Cut(CFX_WideString& wsCut) { 221 FX_BOOL CFWL_Edit::Cut(CFX_WideString& wsCut) {
190 return static_cast<IFWL_Edit*>(m_pIface)->Cut(wsCut); 222 return static_cast<IFWL_Edit*>(m_pIface)->Cut(wsCut);
191 } 223 }
224
192 FX_BOOL CFWL_Edit::Paste(const CFX_WideString& wsPaste) { 225 FX_BOOL CFWL_Edit::Paste(const CFX_WideString& wsPaste) {
193 return static_cast<IFWL_Edit*>(m_pIface)->Paste(wsPaste); 226 return static_cast<IFWL_Edit*>(m_pIface)->Paste(wsPaste);
194 } 227 }
228
195 FX_BOOL CFWL_Edit::Delete() { 229 FX_BOOL CFWL_Edit::Delete() {
196 return static_cast<IFWL_Edit*>(m_pIface)->Delete(); 230 return static_cast<IFWL_Edit*>(m_pIface)->Delete();
197 } 231 }
232
198 void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { 233 void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) {
199 return static_cast<IFWL_Edit*>(m_pIface)->SetScrollOffset(fScrollOffset); 234 return static_cast<IFWL_Edit*>(m_pIface)->SetScrollOffset(fScrollOffset);
200 } 235 }
236
201 FX_BOOL CFWL_Edit::GetSuggestWords(CFX_PointF pointf, 237 FX_BOOL CFWL_Edit::GetSuggestWords(CFX_PointF pointf,
202 std::vector<CFX_ByteString>& sSuggest) { 238 std::vector<CFX_ByteString>& sSuggest) {
203 return static_cast<IFWL_Edit*>(m_pIface)->GetSuggestWords(pointf, sSuggest); 239 return static_cast<IFWL_Edit*>(m_pIface)->GetSuggestWords(pointf, sSuggest);
204 } 240 }
241
205 FX_BOOL CFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, 242 FX_BOOL CFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf,
206 const CFX_ByteStringC& bsReplace) { 243 const CFX_ByteStringC& bsReplace) {
207 return static_cast<IFWL_Edit*>(m_pIface) 244 return static_cast<IFWL_Edit*>(m_pIface)
208 ->ReplaceSpellCheckWord(pointf, bsReplace); 245 ->ReplaceSpellCheckWord(pointf, bsReplace);
209 } 246 }
247
210 CFWL_Edit::CFWL_Edit() {} 248 CFWL_Edit::CFWL_Edit() {}
249
211 CFWL_Edit::~CFWL_Edit() {} 250 CFWL_Edit::~CFWL_Edit() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698