OLD | NEW |
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/fwl/basewidget/fwl_editimp.h" | 7 #include "xfa/fwl/basewidget/fwl_editimp.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 IFWL_Edit* IFWL_Edit::CreateComboEdit( | 67 IFWL_Edit* IFWL_Edit::CreateComboEdit( |
68 const CFWL_WidgetImpProperties& properties, | 68 const CFWL_WidgetImpProperties& properties, |
69 IFWL_Widget* pOuter) { | 69 IFWL_Widget* pOuter) { |
70 IFWL_Edit* pEdit = new IFWL_Edit; | 70 IFWL_Edit* pEdit = new IFWL_Edit; |
71 CFWL_EditImp* pComboEditImpl = new CFWL_ComboEditImp(properties, pOuter); | 71 CFWL_EditImp* pComboEditImpl = new CFWL_ComboEditImp(properties, pOuter); |
72 pEdit->SetImpl(pComboEditImpl); | 72 pEdit->SetImpl(pComboEditImpl); |
73 pComboEditImpl->SetInterface(pEdit); | 73 pComboEditImpl->SetInterface(pEdit); |
74 return pEdit; | 74 return pEdit; |
75 } | 75 } |
76 IFWL_Edit::IFWL_Edit() {} | 76 IFWL_Edit::IFWL_Edit() {} |
77 FWL_ERR IFWL_Edit::SetText(const CFX_WideString& wsText) { | 77 FWL_Error IFWL_Edit::SetText(const CFX_WideString& wsText) { |
78 return static_cast<CFWL_EditImp*>(GetImpl())->SetText(wsText); | 78 return static_cast<CFWL_EditImp*>(GetImpl())->SetText(wsText); |
79 } | 79 } |
80 int32_t IFWL_Edit::GetTextLength() const { | 80 int32_t IFWL_Edit::GetTextLength() const { |
81 return static_cast<CFWL_EditImp*>(GetImpl())->GetTextLength(); | 81 return static_cast<CFWL_EditImp*>(GetImpl())->GetTextLength(); |
82 } | 82 } |
83 FWL_ERR IFWL_Edit::GetText(CFX_WideString& wsText, | 83 FWL_Error IFWL_Edit::GetText(CFX_WideString& wsText, |
84 int32_t nStart, | 84 int32_t nStart, |
85 int32_t nCount) const { | 85 int32_t nCount) const { |
86 return static_cast<CFWL_EditImp*>(GetImpl())->GetText(wsText, nStart, nCount); | 86 return static_cast<CFWL_EditImp*>(GetImpl())->GetText(wsText, nStart, nCount); |
87 } | 87 } |
88 FWL_ERR IFWL_Edit::ClearText() { | 88 FWL_Error IFWL_Edit::ClearText() { |
89 return static_cast<CFWL_EditImp*>(GetImpl())->ClearText(); | 89 return static_cast<CFWL_EditImp*>(GetImpl())->ClearText(); |
90 } | 90 } |
91 int32_t IFWL_Edit::GetCaretPos() const { | 91 int32_t IFWL_Edit::GetCaretPos() const { |
92 return static_cast<CFWL_EditImp*>(GetImpl())->GetCaretPos(); | 92 return static_cast<CFWL_EditImp*>(GetImpl())->GetCaretPos(); |
93 } | 93 } |
94 int32_t IFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { | 94 int32_t IFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { |
95 return static_cast<CFWL_EditImp*>(GetImpl())->SetCaretPos(nIndex, bBefore); | 95 return static_cast<CFWL_EditImp*>(GetImpl())->SetCaretPos(nIndex, bBefore); |
96 } | 96 } |
97 FWL_ERR IFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { | 97 FWL_Error IFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { |
98 return static_cast<CFWL_EditImp*>(GetImpl())->AddSelRange(nStart, nCount); | 98 return static_cast<CFWL_EditImp*>(GetImpl())->AddSelRange(nStart, nCount); |
99 } | 99 } |
100 int32_t IFWL_Edit::CountSelRanges() { | 100 int32_t IFWL_Edit::CountSelRanges() { |
101 return static_cast<CFWL_EditImp*>(GetImpl())->CountSelRanges(); | 101 return static_cast<CFWL_EditImp*>(GetImpl())->CountSelRanges(); |
102 } | 102 } |
103 int32_t IFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { | 103 int32_t IFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { |
104 return static_cast<CFWL_EditImp*>(GetImpl())->GetSelRange(nIndex, nStart); | 104 return static_cast<CFWL_EditImp*>(GetImpl())->GetSelRange(nIndex, nStart); |
105 } | 105 } |
106 FWL_ERR IFWL_Edit::ClearSelections() { | 106 FWL_Error IFWL_Edit::ClearSelections() { |
107 return static_cast<CFWL_EditImp*>(GetImpl())->ClearSelections(); | 107 return static_cast<CFWL_EditImp*>(GetImpl())->ClearSelections(); |
108 } | 108 } |
109 int32_t IFWL_Edit::GetLimit() { | 109 int32_t IFWL_Edit::GetLimit() { |
110 return static_cast<CFWL_EditImp*>(GetImpl())->GetLimit(); | 110 return static_cast<CFWL_EditImp*>(GetImpl())->GetLimit(); |
111 } | 111 } |
112 FWL_ERR IFWL_Edit::SetLimit(int32_t nLimit) { | 112 FWL_Error IFWL_Edit::SetLimit(int32_t nLimit) { |
113 return static_cast<CFWL_EditImp*>(GetImpl())->SetLimit(nLimit); | 113 return static_cast<CFWL_EditImp*>(GetImpl())->SetLimit(nLimit); |
114 } | 114 } |
115 FWL_ERR IFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { | 115 FWL_Error IFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { |
116 return static_cast<CFWL_EditImp*>(GetImpl())->SetAliasChar(wAlias); | 116 return static_cast<CFWL_EditImp*>(GetImpl())->SetAliasChar(wAlias); |
117 } | 117 } |
118 FWL_ERR IFWL_Edit::Insert(int32_t nStart, | 118 FWL_Error IFWL_Edit::Insert(int32_t nStart, |
119 const FX_WCHAR* lpText, | 119 const FX_WCHAR* lpText, |
120 int32_t nLen) { | 120 int32_t nLen) { |
121 return static_cast<CFWL_EditImp*>(GetImpl())->Insert(nStart, lpText, nLen); | 121 return static_cast<CFWL_EditImp*>(GetImpl())->Insert(nStart, lpText, nLen); |
122 } | 122 } |
123 FWL_ERR IFWL_Edit::DeleteSelections() { | 123 FWL_Error IFWL_Edit::DeleteSelections() { |
124 return static_cast<CFWL_EditImp*>(GetImpl())->DeleteSelections(); | 124 return static_cast<CFWL_EditImp*>(GetImpl())->DeleteSelections(); |
125 } | 125 } |
126 FWL_ERR IFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) { | 126 FWL_Error IFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) { |
127 return static_cast<CFWL_EditImp*>(GetImpl())->DeleteRange(nStart, nCount); | 127 return static_cast<CFWL_EditImp*>(GetImpl())->DeleteRange(nStart, nCount); |
128 } | 128 } |
129 FWL_ERR IFWL_Edit::ReplaceSelections(const CFX_WideStringC& wsReplace) { | 129 FWL_Error IFWL_Edit::ReplaceSelections(const CFX_WideStringC& wsReplace) { |
130 return static_cast<CFWL_EditImp*>(GetImpl())->ReplaceSelections(wsReplace); | 130 return static_cast<CFWL_EditImp*>(GetImpl())->ReplaceSelections(wsReplace); |
131 } | 131 } |
132 FWL_ERR IFWL_Edit::Replace(int32_t nStart, | 132 FWL_Error IFWL_Edit::Replace(int32_t nStart, |
133 int32_t nLen, | 133 int32_t nLen, |
134 const CFX_WideStringC& wsReplace) { | 134 const CFX_WideStringC& wsReplace) { |
135 return static_cast<CFWL_EditImp*>(GetImpl()) | 135 return static_cast<CFWL_EditImp*>(GetImpl()) |
136 ->Replace(nStart, nLen, wsReplace); | 136 ->Replace(nStart, nLen, wsReplace); |
137 } | 137 } |
138 FWL_ERR IFWL_Edit::DoClipboard(int32_t iCmd) { | 138 FWL_Error IFWL_Edit::DoClipboard(int32_t iCmd) { |
139 return static_cast<CFWL_EditImp*>(GetImpl())->DoClipboard(iCmd); | 139 return static_cast<CFWL_EditImp*>(GetImpl())->DoClipboard(iCmd); |
140 } | 140 } |
141 FX_BOOL IFWL_Edit::Copy(CFX_WideString& wsCopy) { | 141 FX_BOOL IFWL_Edit::Copy(CFX_WideString& wsCopy) { |
142 return static_cast<CFWL_EditImp*>(GetImpl())->Copy(wsCopy); | 142 return static_cast<CFWL_EditImp*>(GetImpl())->Copy(wsCopy); |
143 } | 143 } |
144 FX_BOOL IFWL_Edit::Cut(CFX_WideString& wsCut) { | 144 FX_BOOL IFWL_Edit::Cut(CFX_WideString& wsCut) { |
145 return static_cast<CFWL_EditImp*>(GetImpl())->Cut(wsCut); | 145 return static_cast<CFWL_EditImp*>(GetImpl())->Cut(wsCut); |
146 } | 146 } |
147 FX_BOOL IFWL_Edit::Paste(const CFX_WideString& wsPaste) { | 147 FX_BOOL IFWL_Edit::Paste(const CFX_WideString& wsPaste) { |
148 return static_cast<CFWL_EditImp*>(GetImpl())->Paste(wsPaste); | 148 return static_cast<CFWL_EditImp*>(GetImpl())->Paste(wsPaste); |
(...skipping 12 matching lines...) Expand all Loading... |
161 } | 161 } |
162 FX_BOOL IFWL_Edit::Redo() { | 162 FX_BOOL IFWL_Edit::Redo() { |
163 return static_cast<CFWL_EditImp*>(GetImpl())->Redo(); | 163 return static_cast<CFWL_EditImp*>(GetImpl())->Redo(); |
164 } | 164 } |
165 FX_BOOL IFWL_Edit::CanUndo() { | 165 FX_BOOL IFWL_Edit::CanUndo() { |
166 return static_cast<CFWL_EditImp*>(GetImpl())->CanUndo(); | 166 return static_cast<CFWL_EditImp*>(GetImpl())->CanUndo(); |
167 } | 167 } |
168 FX_BOOL IFWL_Edit::CanRedo() { | 168 FX_BOOL IFWL_Edit::CanRedo() { |
169 return static_cast<CFWL_EditImp*>(GetImpl())->CanRedo(); | 169 return static_cast<CFWL_EditImp*>(GetImpl())->CanRedo(); |
170 } | 170 } |
171 FWL_ERR IFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { | 171 FWL_Error IFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { |
172 return static_cast<CFWL_EditImp*>(GetImpl()) | 172 return static_cast<CFWL_EditImp*>(GetImpl()) |
173 ->SetTabWidth(fTabWidth, bEquidistant); | 173 ->SetTabWidth(fTabWidth, bEquidistant); |
174 } | 174 } |
175 FWL_ERR IFWL_Edit::SetOuter(IFWL_Widget* pOuter) { | 175 FWL_Error IFWL_Edit::SetOuter(IFWL_Widget* pOuter) { |
176 return static_cast<CFWL_EditImp*>(GetImpl())->SetOuter(pOuter); | 176 return static_cast<CFWL_EditImp*>(GetImpl())->SetOuter(pOuter); |
177 } | 177 } |
178 FWL_ERR IFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { | 178 FWL_Error IFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { |
179 return static_cast<CFWL_EditImp*>(GetImpl())->SetNumberRange(iMin, iMax); | 179 return static_cast<CFWL_EditImp*>(GetImpl())->SetNumberRange(iMin, iMax); |
180 } | 180 } |
181 FWL_ERR IFWL_Edit::SetBackColor(uint32_t dwColor) { | 181 FWL_Error IFWL_Edit::SetBackColor(uint32_t dwColor) { |
182 return static_cast<CFWL_EditImp*>(GetImpl())->SetBackgroundColor(dwColor); | 182 return static_cast<CFWL_EditImp*>(GetImpl())->SetBackgroundColor(dwColor); |
183 } | 183 } |
184 FWL_ERR IFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { | 184 FWL_Error IFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { |
185 return static_cast<CFWL_EditImp*>(GetImpl())->SetFont(wsFont, fSize); | 185 return static_cast<CFWL_EditImp*>(GetImpl())->SetFont(wsFont, fSize); |
186 } | 186 } |
187 void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { | 187 void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { |
188 return static_cast<CFWL_EditImp*>(GetImpl())->SetScrollOffset(fScrollOffset); | 188 return static_cast<CFWL_EditImp*>(GetImpl())->SetScrollOffset(fScrollOffset); |
189 } | 189 } |
190 FX_BOOL IFWL_Edit::GetSuggestWords(CFX_PointF pointf, | 190 FX_BOOL IFWL_Edit::GetSuggestWords(CFX_PointF pointf, |
191 std::vector<CFX_ByteString>& sSuggest) { | 191 std::vector<CFX_ByteString>& sSuggest) { |
192 return static_cast<CFWL_EditImp*>(GetImpl()) | 192 return static_cast<CFWL_EditImp*>(GetImpl()) |
193 ->GetSuggestWords(pointf, sSuggest); | 193 ->GetSuggestWords(pointf, sSuggest); |
194 } | 194 } |
(...skipping 27 matching lines...) Expand all Loading... |
222 m_rtEngine.Reset(); | 222 m_rtEngine.Reset(); |
223 m_rtStatic.Reset(); | 223 m_rtStatic.Reset(); |
224 } | 224 } |
225 CFWL_EditImp::~CFWL_EditImp() { | 225 CFWL_EditImp::~CFWL_EditImp() { |
226 if (m_pEdtEngine) { | 226 if (m_pEdtEngine) { |
227 m_pEdtEngine->Release(); | 227 m_pEdtEngine->Release(); |
228 m_pEdtEngine = NULL; | 228 m_pEdtEngine = NULL; |
229 } | 229 } |
230 ClearRecord(); | 230 ClearRecord(); |
231 } | 231 } |
232 FWL_ERR CFWL_EditImp::GetClassName(CFX_WideString& wsClass) const { | 232 FWL_Error CFWL_EditImp::GetClassName(CFX_WideString& wsClass) const { |
233 wsClass = FWL_CLASS_Edit; | 233 wsClass = FWL_CLASS_Edit; |
234 return FWL_ERR_Succeeded; | 234 return FWL_Error::Succeeded; |
235 } | 235 } |
236 uint32_t CFWL_EditImp::GetClassID() const { | 236 uint32_t CFWL_EditImp::GetClassID() const { |
237 return FWL_CLASSHASH_Edit; | 237 return FWL_CLASSHASH_Edit; |
238 } | 238 } |
239 FWL_ERR CFWL_EditImp::Initialize() { | 239 FWL_Error CFWL_EditImp::Initialize() { |
240 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) | 240 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) |
241 return FWL_ERR_Indefinite; | 241 return FWL_Error::Indefinite; |
242 if (!m_pDelegate) { | 242 if (!m_pDelegate) { |
243 m_pDelegate = new CFWL_EditImpDelegate(this); | 243 m_pDelegate = new CFWL_EditImpDelegate(this); |
244 } | 244 } |
245 InitCaret(); | 245 InitCaret(); |
246 if (!m_pEdtEngine) { | 246 if (!m_pEdtEngine) { |
247 InitEngine(); | 247 InitEngine(); |
248 } | 248 } |
249 return FWL_ERR_Succeeded; | 249 return FWL_Error::Succeeded; |
250 } | 250 } |
251 FWL_ERR CFWL_EditImp::Finalize() { | 251 FWL_Error CFWL_EditImp::Finalize() { |
252 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { | 252 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { |
253 ShowCaret(FALSE); | 253 ShowCaret(FALSE); |
254 } | 254 } |
255 if (m_pHorzScrollBar) { | 255 if (m_pHorzScrollBar) { |
256 m_pHorzScrollBar->Finalize(); | 256 m_pHorzScrollBar->Finalize(); |
257 } | 257 } |
258 if (m_pVertScrollBar) { | 258 if (m_pVertScrollBar) { |
259 m_pVertScrollBar->Finalize(); | 259 m_pVertScrollBar->Finalize(); |
260 } | 260 } |
261 delete m_pDelegate; | 261 delete m_pDelegate; |
262 m_pDelegate = nullptr; | 262 m_pDelegate = nullptr; |
263 return CFWL_WidgetImp::Finalize(); | 263 return CFWL_WidgetImp::Finalize(); |
264 } | 264 } |
265 FWL_ERR CFWL_EditImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 265 FWL_Error CFWL_EditImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
266 if (bAutoSize) { | 266 if (bAutoSize) { |
267 rect.Set(0, 0, 0, 0); | 267 rect.Set(0, 0, 0, 0); |
268 if (m_pEdtEngine) { | 268 if (m_pEdtEngine) { |
269 int32_t iTextLen = m_pEdtEngine->GetTextLength(); | 269 int32_t iTextLen = m_pEdtEngine->GetTextLength(); |
270 if (iTextLen > 0) { | 270 if (iTextLen > 0) { |
271 CFX_WideString wsText; | 271 CFX_WideString wsText; |
272 m_pEdtEngine->GetText(wsText, 0); | 272 m_pEdtEngine->GetText(wsText, 0); |
273 CFX_SizeF sz = CalcTextSize( | 273 CFX_SizeF sz = CalcTextSize( |
274 wsText, m_pProperties->m_pThemeProvider, | 274 wsText, m_pProperties->m_pThemeProvider, |
275 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); | 275 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); |
(...skipping 11 matching lines...) Expand all Loading... |
287 rect.width += kEditMargin; | 287 rect.width += kEditMargin; |
288 } | 288 } |
289 if (IsShowScrollBar(FALSE)) { | 289 if (IsShowScrollBar(FALSE)) { |
290 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( | 290 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( |
291 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); | 291 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
292 rect.height += *pfWidth; | 292 rect.height += *pfWidth; |
293 rect.height += kEditMargin; | 293 rect.height += kEditMargin; |
294 } | 294 } |
295 } | 295 } |
296 } | 296 } |
297 return FWL_ERR_Succeeded; | 297 return FWL_Error::Succeeded; |
298 } | 298 } |
299 | 299 |
300 void CFWL_EditImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { | 300 void CFWL_EditImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { |
301 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) || | 301 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) || |
302 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { | 302 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { |
303 ShowCaret(FALSE); | 303 ShowCaret(FALSE); |
304 } | 304 } |
305 CFWL_WidgetImp::SetStates(dwStates, bSet); | 305 CFWL_WidgetImp::SetStates(dwStates, bSet); |
306 } | 306 } |
307 | 307 |
308 FWL_ERR CFWL_EditImp::SetWidgetRect(const CFX_RectF& rect) { | 308 FWL_Error CFWL_EditImp::SetWidgetRect(const CFX_RectF& rect) { |
309 return CFWL_WidgetImp::SetWidgetRect(rect); | 309 return CFWL_WidgetImp::SetWidgetRect(rect); |
310 } | 310 } |
311 FWL_ERR CFWL_EditImp::Update() { | 311 FWL_Error CFWL_EditImp::Update() { |
312 if (IsLocked()) { | 312 if (IsLocked()) { |
313 return FWL_ERR_Indefinite; | 313 return FWL_Error::Indefinite; |
314 } | 314 } |
315 if (!m_pProperties->m_pThemeProvider) { | 315 if (!m_pProperties->m_pThemeProvider) { |
316 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 316 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
317 } | 317 } |
318 Layout(); | 318 Layout(); |
319 if (m_rtClient.IsEmpty()) { | 319 if (m_rtClient.IsEmpty()) { |
320 return FWL_ERR_Indefinite; | 320 return FWL_Error::Indefinite; |
321 } | 321 } |
322 UpdateEditEngine(); | 322 UpdateEditEngine(); |
323 UpdateVAlignment(); | 323 UpdateVAlignment(); |
324 UpdateScroll(); | 324 UpdateScroll(); |
325 InitCaret(); | 325 InitCaret(); |
326 return FWL_ERR_Succeeded; | 326 return FWL_Error::Succeeded; |
327 } | 327 } |
328 | 328 |
329 FWL_WidgetHit CFWL_EditImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 329 FWL_WidgetHit CFWL_EditImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
330 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { | 330 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { |
331 if (IsShowScrollBar(TRUE)) { | 331 if (IsShowScrollBar(TRUE)) { |
332 CFX_RectF rect; | 332 CFX_RectF rect; |
333 m_pVertScrollBar->GetWidgetRect(rect); | 333 m_pVertScrollBar->GetWidgetRect(rect); |
334 if (rect.Contains(fx, fy)) | 334 if (rect.Contains(fx, fy)) |
335 return FWL_WidgetHit::VScrollBar; | 335 return FWL_WidgetHit::VScrollBar; |
336 } | 336 } |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 pMatrix->TransformRect(rtClip); | 485 pMatrix->TransformRect(rtClip); |
486 mt.Concat(*pMatrix); | 486 mt.Concat(*pMatrix); |
487 } | 487 } |
488 pGraphics->SetClipRect(rtClip); | 488 pGraphics->SetClipRect(rtClip); |
489 pGraphics->SetStrokeColor(&crLine); | 489 pGraphics->SetStrokeColor(&crLine); |
490 pGraphics->SetLineWidth(0); | 490 pGraphics->SetLineWidth(0); |
491 pGraphics->StrokePath(&pathSpell, NULL); | 491 pGraphics->StrokePath(&pathSpell, NULL); |
492 } | 492 } |
493 pGraphics->RestoreGraphState(); | 493 pGraphics->RestoreGraphState(); |
494 } | 494 } |
495 FWL_ERR CFWL_EditImp::DrawWidget(CFX_Graphics* pGraphics, | 495 FWL_Error CFWL_EditImp::DrawWidget(CFX_Graphics* pGraphics, |
496 const CFX_Matrix* pMatrix) { | 496 const CFX_Matrix* pMatrix) { |
497 if (!pGraphics) | 497 if (!pGraphics) |
498 return FWL_ERR_Indefinite; | 498 return FWL_Error::Indefinite; |
499 if (!m_pProperties->m_pThemeProvider) | 499 if (!m_pProperties->m_pThemeProvider) |
500 return FWL_ERR_Indefinite; | 500 return FWL_Error::Indefinite; |
501 if (m_rtClient.IsEmpty()) { | 501 if (m_rtClient.IsEmpty()) { |
502 return FWL_ERR_Indefinite; | 502 return FWL_Error::Indefinite; |
503 } | 503 } |
504 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 504 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
505 if (!m_pWidgetMgr->IsFormDisabled()) { | 505 if (!m_pWidgetMgr->IsFormDisabled()) { |
506 DrawTextBk(pGraphics, pTheme, pMatrix); | 506 DrawTextBk(pGraphics, pTheme, pMatrix); |
507 } | 507 } |
508 if (m_pEdtEngine) { | 508 if (m_pEdtEngine) { |
509 DrawContent(pGraphics, pTheme, pMatrix); | 509 DrawContent(pGraphics, pTheme, pMatrix); |
510 } | 510 } |
511 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && | 511 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && |
512 !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)) { | 512 !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)) { |
513 DrawSpellCheck(pGraphics, pMatrix); | 513 DrawSpellCheck(pGraphics, pMatrix); |
514 } | 514 } |
515 if (HasBorder()) { | 515 if (HasBorder()) { |
516 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); | 516 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); |
517 } | 517 } |
518 if (HasEdge()) { | 518 if (HasEdge()) { |
519 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 519 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
520 } | 520 } |
521 return FWL_ERR_Succeeded; | 521 return FWL_Error::Succeeded; |
522 } | 522 } |
523 FWL_ERR CFWL_EditImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | 523 FWL_Error CFWL_EditImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { |
524 if (!pThemeProvider) | 524 if (!pThemeProvider) |
525 return FWL_ERR_Indefinite; | 525 return FWL_Error::Indefinite; |
526 if (m_pHorzScrollBar) { | 526 if (m_pHorzScrollBar) { |
527 m_pHorzScrollBar->SetThemeProvider(pThemeProvider); | 527 m_pHorzScrollBar->SetThemeProvider(pThemeProvider); |
528 } | 528 } |
529 if (m_pVertScrollBar) { | 529 if (m_pVertScrollBar) { |
530 m_pVertScrollBar->SetThemeProvider(pThemeProvider); | 530 m_pVertScrollBar->SetThemeProvider(pThemeProvider); |
531 } | 531 } |
532 if (m_pCaret) { | 532 if (m_pCaret) { |
533 m_pCaret->SetThemeProvider(pThemeProvider); | 533 m_pCaret->SetThemeProvider(pThemeProvider); |
534 } | 534 } |
535 m_pProperties->m_pThemeProvider = pThemeProvider; | 535 m_pProperties->m_pThemeProvider = pThemeProvider; |
536 return FWL_ERR_Succeeded; | 536 return FWL_Error::Succeeded; |
537 } | 537 } |
538 FWL_ERR CFWL_EditImp::SetText(const CFX_WideString& wsText) { | 538 |
| 539 FWL_Error CFWL_EditImp::SetText(const CFX_WideString& wsText) { |
539 m_pEdtEngine->SetText(wsText); | 540 m_pEdtEngine->SetText(wsText); |
540 return FWL_ERR_Succeeded; | 541 return FWL_Error::Succeeded; |
541 } | 542 } |
| 543 |
542 int32_t CFWL_EditImp::GetTextLength() const { | 544 int32_t CFWL_EditImp::GetTextLength() const { |
543 if (!m_pEdtEngine) | 545 if (!m_pEdtEngine) |
544 return -1; | 546 return -1; |
545 return m_pEdtEngine->GetTextLength(); | 547 return m_pEdtEngine->GetTextLength(); |
546 } | 548 } |
547 FWL_ERR CFWL_EditImp::GetText(CFX_WideString& wsText, | 549 |
548 int32_t nStart, | 550 FWL_Error CFWL_EditImp::GetText(CFX_WideString& wsText, |
549 int32_t nCount) const { | 551 int32_t nStart, |
| 552 int32_t nCount) const { |
550 if (!m_pEdtEngine) | 553 if (!m_pEdtEngine) |
551 return FWL_ERR_Succeeded; | 554 return FWL_Error::Indefinite; |
| 555 |
552 m_pEdtEngine->GetText(wsText, nStart, nCount); | 556 m_pEdtEngine->GetText(wsText, nStart, nCount); |
553 return FWL_ERR_Succeeded; | 557 return FWL_Error::Succeeded; |
554 } | 558 } |
555 FWL_ERR CFWL_EditImp::ClearText() { | 559 |
| 560 FWL_Error CFWL_EditImp::ClearText() { |
556 if (!m_pEdtEngine) | 561 if (!m_pEdtEngine) |
557 return FWL_ERR_Succeeded; | 562 return FWL_Error::Indefinite; |
| 563 |
558 m_pEdtEngine->ClearText(); | 564 m_pEdtEngine->ClearText(); |
559 return FWL_ERR_Succeeded; | 565 return FWL_Error::Succeeded; |
560 } | 566 } |
| 567 |
561 int32_t CFWL_EditImp::GetCaretPos() const { | 568 int32_t CFWL_EditImp::GetCaretPos() const { |
562 if (!m_pEdtEngine) | 569 if (!m_pEdtEngine) |
563 return -1; | 570 return -1; |
564 return m_pEdtEngine->GetCaretPos(); | 571 return m_pEdtEngine->GetCaretPos(); |
565 } | 572 } |
| 573 |
566 int32_t CFWL_EditImp::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { | 574 int32_t CFWL_EditImp::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { |
567 if (!m_pEdtEngine) | 575 if (!m_pEdtEngine) |
568 return -1; | 576 return -1; |
569 return m_pEdtEngine->SetCaretPos(nIndex, bBefore); | 577 return m_pEdtEngine->SetCaretPos(nIndex, bBefore); |
570 } | 578 } |
571 FWL_ERR CFWL_EditImp::AddSelRange(int32_t nStart, int32_t nCount) { | 579 |
| 580 FWL_Error CFWL_EditImp::AddSelRange(int32_t nStart, int32_t nCount) { |
572 if (!m_pEdtEngine) | 581 if (!m_pEdtEngine) |
573 return FWL_ERR_Succeeded; | 582 return FWL_Error::Indefinite; |
| 583 |
574 m_pEdtEngine->AddSelRange(nStart, nCount); | 584 m_pEdtEngine->AddSelRange(nStart, nCount); |
575 return FWL_ERR_Succeeded; | 585 return FWL_Error::Succeeded; |
576 } | 586 } |
| 587 |
577 int32_t CFWL_EditImp::CountSelRanges() { | 588 int32_t CFWL_EditImp::CountSelRanges() { |
578 if (!m_pEdtEngine) | 589 if (!m_pEdtEngine) |
579 return 0; | 590 return 0; |
580 return m_pEdtEngine->CountSelRanges(); | 591 return m_pEdtEngine->CountSelRanges(); |
581 return FWL_ERR_Succeeded; | |
582 } | 592 } |
| 593 |
583 int32_t CFWL_EditImp::GetSelRange(int32_t nIndex, int32_t& nStart) { | 594 int32_t CFWL_EditImp::GetSelRange(int32_t nIndex, int32_t& nStart) { |
584 if (!m_pEdtEngine) | 595 if (!m_pEdtEngine) |
585 return -1; | 596 return -1; |
586 return m_pEdtEngine->GetSelRange(nIndex, nStart); | 597 return m_pEdtEngine->GetSelRange(nIndex, nStart); |
587 } | 598 } |
588 FWL_ERR CFWL_EditImp::ClearSelections() { | 599 |
| 600 FWL_Error CFWL_EditImp::ClearSelections() { |
589 if (!m_pEdtEngine) | 601 if (!m_pEdtEngine) |
590 return FWL_ERR_Succeeded; | 602 return FWL_Error::Indefinite; |
| 603 |
591 m_pEdtEngine->ClearSelection(); | 604 m_pEdtEngine->ClearSelection(); |
592 return FWL_ERR_Succeeded; | 605 return FWL_Error::Succeeded; |
593 } | 606 } |
| 607 |
594 int32_t CFWL_EditImp::GetLimit() { | 608 int32_t CFWL_EditImp::GetLimit() { |
595 return m_nLimit; | 609 return m_nLimit; |
596 } | 610 } |
597 FWL_ERR CFWL_EditImp::SetLimit(int32_t nLimit) { | 611 |
| 612 FWL_Error CFWL_EditImp::SetLimit(int32_t nLimit) { |
598 m_nLimit = nLimit; | 613 m_nLimit = nLimit; |
599 if (!m_pEdtEngine) | 614 if (!m_pEdtEngine) |
600 return FWL_ERR_Succeeded; | 615 return FWL_Error::Indefinite; |
| 616 |
601 m_pEdtEngine->SetLimit(nLimit); | 617 m_pEdtEngine->SetLimit(nLimit); |
602 return FWL_ERR_Succeeded; | 618 return FWL_Error::Succeeded; |
603 } | 619 } |
604 FWL_ERR CFWL_EditImp::SetAliasChar(FX_WCHAR wAlias) { | 620 |
| 621 FWL_Error CFWL_EditImp::SetAliasChar(FX_WCHAR wAlias) { |
605 if (!m_pEdtEngine) | 622 if (!m_pEdtEngine) |
606 return FWL_ERR_Indefinite; | 623 return FWL_Error::Indefinite; |
| 624 |
607 m_pEdtEngine->SetAliasChar(wAlias); | 625 m_pEdtEngine->SetAliasChar(wAlias); |
608 return FWL_ERR_Succeeded; | 626 return FWL_Error::Succeeded; |
609 } | 627 } |
610 FWL_ERR CFWL_EditImp::Insert(int32_t nStart, | 628 |
611 const FX_WCHAR* lpText, | 629 FWL_Error CFWL_EditImp::Insert(int32_t nStart, |
612 int32_t nLen) { | 630 const FX_WCHAR* lpText, |
| 631 int32_t nLen) { |
613 if (!m_pEdtEngine) | 632 if (!m_pEdtEngine) |
614 return FWL_ERR_Succeeded; | 633 return FWL_Error::Indefinite; |
| 634 |
615 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || | 635 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || |
616 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { | 636 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { |
617 return FWL_ERR_Indefinite; | 637 return FWL_Error::Indefinite; |
618 } | 638 } |
619 m_pEdtEngine->Insert(nStart, lpText, nLen); | 639 m_pEdtEngine->Insert(nStart, lpText, nLen); |
620 return FWL_ERR_Succeeded; | 640 return FWL_Error::Succeeded; |
621 } | 641 } |
622 FWL_ERR CFWL_EditImp::DeleteSelections() { | 642 |
| 643 FWL_Error CFWL_EditImp::DeleteSelections() { |
623 if (!m_pEdtEngine) | 644 if (!m_pEdtEngine) |
624 return FWL_ERR_Succeeded; | 645 return FWL_Error::Indefinite; |
| 646 |
625 int32_t iCount = m_pEdtEngine->CountSelRanges(); | 647 int32_t iCount = m_pEdtEngine->CountSelRanges(); |
626 if (iCount > 0) { | 648 if (iCount > 0) |
627 m_pEdtEngine->Delete(-1); | 649 m_pEdtEngine->Delete(-1); |
628 } | 650 return FWL_Error::Succeeded; |
629 return FWL_ERR_Succeeded; | |
630 } | 651 } |
631 FWL_ERR CFWL_EditImp::DeleteRange(int32_t nStart, int32_t nCount) { | 652 |
| 653 FWL_Error CFWL_EditImp::DeleteRange(int32_t nStart, int32_t nCount) { |
632 if (!m_pEdtEngine) | 654 if (!m_pEdtEngine) |
633 return FWL_ERR_Succeeded; | 655 return FWL_Error::Indefinite; |
| 656 |
634 m_pEdtEngine->DeleteRange(nStart, nCount); | 657 m_pEdtEngine->DeleteRange(nStart, nCount); |
635 return FWL_ERR_Succeeded; | 658 return FWL_Error::Succeeded; |
636 } | 659 } |
637 FWL_ERR CFWL_EditImp::ReplaceSelections(const CFX_WideStringC& wsReplace) { | 660 |
| 661 FWL_Error CFWL_EditImp::ReplaceSelections(const CFX_WideStringC& wsReplace) { |
638 if (!m_pEdtEngine) | 662 if (!m_pEdtEngine) |
639 return FWL_ERR_Succeeded; | 663 return FWL_Error::Indefinite; |
| 664 |
640 int32_t iCount = m_pEdtEngine->CountSelRanges(); | 665 int32_t iCount = m_pEdtEngine->CountSelRanges(); |
641 for (int i = 0; i < iCount; i++) { | 666 for (int i = 0; i < iCount; i++) { |
642 int32_t nStart; | 667 int32_t nStart; |
643 int32_t nCount = m_pEdtEngine->GetSelRange(i, nStart); | 668 int32_t nCount = m_pEdtEngine->GetSelRange(i, nStart); |
644 m_pEdtEngine->Replace(nStart, nCount, wsReplace); | 669 m_pEdtEngine->Replace(nStart, nCount, wsReplace); |
645 } | 670 } |
646 return FWL_ERR_Succeeded; | 671 return FWL_Error::Succeeded; |
647 } | 672 } |
648 FWL_ERR CFWL_EditImp::Replace(int32_t nStart, | 673 |
649 int32_t nLen, | 674 FWL_Error CFWL_EditImp::Replace(int32_t nStart, |
650 const CFX_WideStringC& wsReplace) { | 675 int32_t nLen, |
| 676 const CFX_WideStringC& wsReplace) { |
651 if (!m_pEdtEngine) | 677 if (!m_pEdtEngine) |
652 return FWL_ERR_Succeeded; | 678 return FWL_Error::Indefinite; |
| 679 |
653 m_pEdtEngine->Replace(nStart, nLen, wsReplace); | 680 m_pEdtEngine->Replace(nStart, nLen, wsReplace); |
654 return FWL_ERR_Succeeded; | 681 return FWL_Error::Succeeded; |
655 } | 682 } |
656 FWL_ERR CFWL_EditImp::DoClipboard(int32_t iCmd) { | 683 |
| 684 FWL_Error CFWL_EditImp::DoClipboard(int32_t iCmd) { |
657 if (!m_pEdtEngine) | 685 if (!m_pEdtEngine) |
658 return FWL_ERR_Succeeded; | 686 return FWL_Error::Indefinite; |
| 687 |
659 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || | 688 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || |
660 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { | 689 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { |
661 return FWL_ERR_Succeeded; | 690 return FWL_Error::Succeeded; |
662 } | 691 } |
663 return FWL_ERR_Indefinite; | 692 return FWL_Error::Indefinite; |
664 } | 693 } |
| 694 |
665 FX_BOOL CFWL_EditImp::Copy(CFX_WideString& wsCopy) { | 695 FX_BOOL CFWL_EditImp::Copy(CFX_WideString& wsCopy) { |
666 if (!m_pEdtEngine) | 696 if (!m_pEdtEngine) |
667 return FALSE; | 697 return FALSE; |
| 698 |
668 int32_t nCount = m_pEdtEngine->CountSelRanges(); | 699 int32_t nCount = m_pEdtEngine->CountSelRanges(); |
669 if (nCount == 0) { | 700 if (nCount == 0) |
670 return FALSE; | 701 return FALSE; |
671 } | 702 |
672 wsCopy.clear(); | 703 wsCopy.clear(); |
673 CFX_WideString wsTemp; | 704 CFX_WideString wsTemp; |
674 int32_t nStart, nLength; | 705 int32_t nStart, nLength; |
675 for (int32_t i = 0; i < nCount; i++) { | 706 for (int32_t i = 0; i < nCount; i++) { |
676 nLength = m_pEdtEngine->GetSelRange(i, nStart); | 707 nLength = m_pEdtEngine->GetSelRange(i, nStart); |
677 m_pEdtEngine->GetText(wsTemp, nStart, nLength); | 708 m_pEdtEngine->GetText(wsTemp, nStart, nLength); |
678 wsCopy += wsTemp; | 709 wsCopy += wsTemp; |
679 wsTemp.clear(); | 710 wsTemp.clear(); |
680 } | 711 } |
681 return TRUE; | 712 return TRUE; |
682 } | 713 } |
| 714 |
683 FX_BOOL CFWL_EditImp::Cut(CFX_WideString& wsCut) { | 715 FX_BOOL CFWL_EditImp::Cut(CFX_WideString& wsCut) { |
684 if (!m_pEdtEngine) | 716 if (!m_pEdtEngine) |
685 return FALSE; | 717 return FALSE; |
| 718 |
686 int32_t nCount = m_pEdtEngine->CountSelRanges(); | 719 int32_t nCount = m_pEdtEngine->CountSelRanges(); |
687 if (nCount == 0) { | 720 if (nCount == 0) |
688 return FALSE; | 721 return FALSE; |
689 } | 722 |
690 wsCut.clear(); | 723 wsCut.clear(); |
691 CFX_WideString wsTemp; | 724 CFX_WideString wsTemp; |
692 int32_t nStart, nLength; | 725 int32_t nStart, nLength; |
693 for (int32_t i = 0; i < nCount; i++) { | 726 for (int32_t i = 0; i < nCount; i++) { |
694 nLength = m_pEdtEngine->GetSelRange(i, nStart); | 727 nLength = m_pEdtEngine->GetSelRange(i, nStart); |
695 m_pEdtEngine->GetText(wsTemp, nStart, nLength); | 728 m_pEdtEngine->GetText(wsTemp, nStart, nLength); |
696 wsCut += wsTemp; | 729 wsCut += wsTemp; |
697 wsTemp.clear(); | 730 wsTemp.clear(); |
698 } | 731 } |
699 m_pEdtEngine->Delete(0); | 732 m_pEdtEngine->Delete(0); |
700 return TRUE; | 733 return TRUE; |
701 } | 734 } |
| 735 |
702 FX_BOOL CFWL_EditImp::Paste(const CFX_WideString& wsPaste) { | 736 FX_BOOL CFWL_EditImp::Paste(const CFX_WideString& wsPaste) { |
703 if (!m_pEdtEngine) | 737 if (!m_pEdtEngine) |
704 return FALSE; | 738 return FALSE; |
| 739 |
705 int32_t nCaret = m_pEdtEngine->GetCaretPos(); | 740 int32_t nCaret = m_pEdtEngine->GetCaretPos(); |
706 int32_t iError = | 741 int32_t iError = |
707 m_pEdtEngine->Insert(nCaret, wsPaste.c_str(), wsPaste.GetLength()); | 742 m_pEdtEngine->Insert(nCaret, wsPaste.c_str(), wsPaste.GetLength()); |
708 if (iError < 0) { | 743 if (iError < 0) { |
709 ProcessInsertError(iError); | 744 ProcessInsertError(iError); |
710 return FALSE; | 745 return FALSE; |
711 } | 746 } |
712 return TRUE; | 747 return TRUE; |
713 } | 748 } |
| 749 |
714 FX_BOOL CFWL_EditImp::Delete() { | 750 FX_BOOL CFWL_EditImp::Delete() { |
715 if (!m_pEdtEngine) | 751 if (!m_pEdtEngine) |
716 return FALSE; | 752 return FALSE; |
| 753 |
717 int32_t nCount = m_pEdtEngine->CountSelRanges(); | 754 int32_t nCount = m_pEdtEngine->CountSelRanges(); |
718 if (nCount < 1) { | 755 if (nCount < 1) |
719 return FALSE; | 756 return FALSE; |
720 } | 757 |
721 m_pEdtEngine->Delete(0); | 758 m_pEdtEngine->Delete(0); |
722 return TRUE; | 759 return TRUE; |
723 } | 760 } |
| 761 |
724 FX_BOOL CFWL_EditImp::Redo(const CFX_ByteStringC& bsRecord) { | 762 FX_BOOL CFWL_EditImp::Redo(const CFX_ByteStringC& bsRecord) { |
725 if (!m_pEdtEngine) | 763 if (!m_pEdtEngine) |
726 return FALSE; | 764 return FALSE; |
727 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) { | 765 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) |
728 return TRUE; | 766 return TRUE; |
729 } | |
730 return m_pEdtEngine->Redo(bsRecord); | 767 return m_pEdtEngine->Redo(bsRecord); |
731 } | 768 } |
| 769 |
732 FX_BOOL CFWL_EditImp::Undo(const CFX_ByteStringC& bsRecord) { | 770 FX_BOOL CFWL_EditImp::Undo(const CFX_ByteStringC& bsRecord) { |
733 if (!m_pEdtEngine) | 771 if (!m_pEdtEngine) |
734 return FALSE; | 772 return FALSE; |
735 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) { | 773 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) |
736 return TRUE; | 774 return TRUE; |
737 } | |
738 return m_pEdtEngine->Undo(bsRecord); | 775 return m_pEdtEngine->Undo(bsRecord); |
739 } | 776 } |
| 777 |
740 FX_BOOL CFWL_EditImp::Undo() { | 778 FX_BOOL CFWL_EditImp::Undo() { |
741 if (!CanUndo()) { | 779 if (!CanUndo()) |
742 return FALSE; | 780 return FALSE; |
743 } | 781 |
744 CFX_ByteString bsRecord = m_RecordArr[m_iCurRecord--]; | 782 CFX_ByteString bsRecord = m_RecordArr[m_iCurRecord--]; |
745 return Undo(bsRecord.AsStringC()); | 783 return Undo(bsRecord.AsStringC()); |
746 } | 784 } |
| 785 |
747 FX_BOOL CFWL_EditImp::Redo() { | 786 FX_BOOL CFWL_EditImp::Redo() { |
748 if (!CanRedo()) { | 787 if (!CanRedo()) |
749 return FALSE; | 788 return FALSE; |
750 } | 789 |
751 CFX_ByteString bsRecord = m_RecordArr[++m_iCurRecord]; | 790 CFX_ByteString bsRecord = m_RecordArr[++m_iCurRecord]; |
752 return Redo(bsRecord.AsStringC()); | 791 return Redo(bsRecord.AsStringC()); |
753 } | 792 } |
| 793 |
754 FX_BOOL CFWL_EditImp::CanUndo() { | 794 FX_BOOL CFWL_EditImp::CanUndo() { |
755 return m_iCurRecord >= 0; | 795 return m_iCurRecord >= 0; |
756 } | 796 } |
| 797 |
757 FX_BOOL CFWL_EditImp::CanRedo() { | 798 FX_BOOL CFWL_EditImp::CanRedo() { |
758 return m_iCurRecord < m_RecordArr.GetSize() - 1; | 799 return m_iCurRecord < m_RecordArr.GetSize() - 1; |
759 } | 800 } |
760 FWL_ERR CFWL_EditImp::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { | 801 |
| 802 FWL_Error CFWL_EditImp::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { |
761 if (!m_pEdtEngine) | 803 if (!m_pEdtEngine) |
762 return FWL_ERR_Succeeded; | 804 return FWL_Error::Indefinite; |
| 805 |
763 FDE_TXTEDTPARAMS* pParams = m_pEdtEngine->GetEditParams(); | 806 FDE_TXTEDTPARAMS* pParams = m_pEdtEngine->GetEditParams(); |
764 pParams->fTabWidth = fTabWidth; | 807 pParams->fTabWidth = fTabWidth; |
765 pParams->bTabEquidistant = bEquidistant; | 808 pParams->bTabEquidistant = bEquidistant; |
766 return FWL_ERR_Succeeded; | 809 return FWL_Error::Succeeded; |
767 } | 810 } |
768 FWL_ERR CFWL_EditImp::SetOuter(IFWL_Widget* pOuter) { | 811 |
| 812 FWL_Error CFWL_EditImp::SetOuter(IFWL_Widget* pOuter) { |
769 m_pOuter = pOuter; | 813 m_pOuter = pOuter; |
770 return FWL_ERR_Succeeded; | 814 return FWL_Error::Succeeded; |
771 } | 815 } |
772 FWL_ERR CFWL_EditImp::SetNumberRange(int32_t iMin, int32_t iMax) { | 816 |
| 817 FWL_Error CFWL_EditImp::SetNumberRange(int32_t iMin, int32_t iMax) { |
773 m_iMin = iMin; | 818 m_iMin = iMin; |
774 m_iMax = iMax; | 819 m_iMax = iMax; |
775 m_bSetRange = TRUE; | 820 m_bSetRange = TRUE; |
776 return FWL_ERR_Succeeded; | 821 return FWL_Error::Succeeded; |
777 } | 822 } |
| 823 |
778 void CFWL_EditImp::On_CaretChanged(CFDE_TxtEdtEngine* pEdit, | 824 void CFWL_EditImp::On_CaretChanged(CFDE_TxtEdtEngine* pEdit, |
779 int32_t nPage, | 825 int32_t nPage, |
780 FX_BOOL bVisible) { | 826 FX_BOOL bVisible) { |
781 if (m_rtEngine.IsEmpty()) { | 827 if (m_rtEngine.IsEmpty()) |
782 return; | 828 return; |
783 } | 829 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) |
784 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { | |
785 return; | 830 return; |
786 } | 831 |
787 FX_BOOL bRepaintContent = UpdateOffset(); | 832 FX_BOOL bRepaintContent = UpdateOffset(); |
788 UpdateCaret(); | 833 UpdateCaret(); |
789 CFX_RectF rtInvalid; | 834 CFX_RectF rtInvalid; |
790 rtInvalid.Set(0, 0, 0, 0); | 835 rtInvalid.Set(0, 0, 0, 0); |
791 FX_BOOL bRepaintScroll = FALSE; | 836 FX_BOOL bRepaintScroll = FALSE; |
792 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { | 837 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { |
793 IFWL_ScrollBar* pScroll = UpdateScroll(); | 838 IFWL_ScrollBar* pScroll = UpdateScroll(); |
794 if (pScroll) { | 839 if (pScroll) { |
795 pScroll->GetWidgetRect(rtInvalid); | 840 pScroll->GetWidgetRect(rtInvalid); |
796 bRepaintScroll = TRUE; | 841 bRepaintScroll = TRUE; |
797 } | 842 } |
798 } | 843 } |
799 if (bRepaintContent || bRepaintScroll) { | 844 if (bRepaintContent || bRepaintScroll) { |
800 if (bRepaintContent) { | 845 if (bRepaintContent) { |
801 rtInvalid.Union(m_rtEngine); | 846 rtInvalid.Union(m_rtEngine); |
802 } | 847 } |
803 Repaint(&rtInvalid); | 848 Repaint(&rtInvalid); |
804 } | 849 } |
805 } | 850 } |
| 851 |
806 void CFWL_EditImp::On_TextChanged(CFDE_TxtEdtEngine* pEdit, | 852 void CFWL_EditImp::On_TextChanged(CFDE_TxtEdtEngine* pEdit, |
807 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { | 853 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { |
808 uint32_t dwStyleEx = m_pProperties->m_dwStyleExes; | 854 uint32_t dwStyleEx = m_pProperties->m_dwStyleExes; |
809 if (dwStyleEx & FWL_STYLEEXT_EDT_VAlignMask) { | 855 if (dwStyleEx & FWL_STYLEEXT_EDT_VAlignMask) |
810 UpdateVAlignment(); | 856 UpdateVAlignment(); |
811 } | 857 |
812 IFDE_TxtEdtPage* page = m_pEdtEngine->GetPage(0); | 858 IFDE_TxtEdtPage* page = m_pEdtEngine->GetPage(0); |
813 FX_FLOAT fContentWidth = page->GetContentsBox().width; | 859 FX_FLOAT fContentWidth = page->GetContentsBox().width; |
814 FX_FLOAT fContentHeight = page->GetContentsBox().height; | 860 FX_FLOAT fContentHeight = page->GetContentsBox().height; |
815 CFX_RectF rtTemp; | 861 CFX_RectF rtTemp; |
816 GetClientRect(rtTemp); | 862 GetClientRect(rtTemp); |
817 FX_BOOL bHSelfAdaption = | 863 FX_BOOL bHSelfAdaption = |
818 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption; | 864 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption; |
819 FX_BOOL bVSelfAdaption = | 865 FX_BOOL bVSelfAdaption = |
820 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption; | 866 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption; |
821 FX_BOOL bNeedUpdate = FALSE; | 867 FX_BOOL bNeedUpdate = FALSE; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 pDst = m_pInterface; | 952 pDst = m_pInterface; |
907 } | 953 } |
908 CFWL_EvtEdtValidate event; | 954 CFWL_EvtEdtValidate event; |
909 event.pDstWidget = pDst; | 955 event.pDstWidget = pDst; |
910 event.m_pSrcTarget = m_pInterface; | 956 event.m_pSrcTarget = m_pInterface; |
911 event.wsInsert = wsText; | 957 event.wsInsert = wsText; |
912 event.bValidate = TRUE; | 958 event.bValidate = TRUE; |
913 DispatchEvent(&event); | 959 DispatchEvent(&event); |
914 return event.bValidate; | 960 return event.bValidate; |
915 } | 961 } |
916 FWL_ERR CFWL_EditImp::SetBackgroundColor(uint32_t color) { | 962 FWL_Error CFWL_EditImp::SetBackgroundColor(uint32_t color) { |
917 m_backColor = color; | 963 m_backColor = color; |
918 m_updateBackColor = TRUE; | 964 m_updateBackColor = TRUE; |
919 return FWL_ERR_Succeeded; | 965 return FWL_Error::Succeeded; |
920 } | 966 } |
921 FWL_ERR CFWL_EditImp::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { | 967 FWL_Error CFWL_EditImp::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { |
922 m_wsFont = wsFont; | 968 m_wsFont = wsFont; |
923 m_fFontSize = fSize; | 969 m_fFontSize = fSize; |
924 return FWL_ERR_Succeeded; | 970 return FWL_Error::Succeeded; |
925 } | 971 } |
926 void CFWL_EditImp::SetScrollOffset(FX_FLOAT fScrollOffset) { | 972 void CFWL_EditImp::SetScrollOffset(FX_FLOAT fScrollOffset) { |
927 m_fScrollOffsetY = fScrollOffset; | 973 m_fScrollOffsetY = fScrollOffset; |
928 } | 974 } |
929 void CFWL_EditImp::DrawTextBk(CFX_Graphics* pGraphics, | 975 void CFWL_EditImp::DrawTextBk(CFX_Graphics* pGraphics, |
930 IFWL_ThemeProvider* pTheme, | 976 IFWL_ThemeProvider* pTheme, |
931 const CFX_Matrix* pMatrix) { | 977 const CFX_Matrix* pMatrix) { |
932 CFWL_ThemeBackground param; | 978 CFWL_ThemeBackground param; |
933 param.m_pWidget = m_pInterface; | 979 param.m_pWidget = m_pInterface; |
934 param.m_iPart = CFWL_Part::Background; | 980 param.m_iPart = CFWL_Part::Background; |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1711 DispatchEvent(&textFullEvent); | 1757 DispatchEvent(&textFullEvent); |
1712 break; | 1758 break; |
1713 } | 1759 } |
1714 default: {} | 1760 default: {} |
1715 } | 1761 } |
1716 } | 1762 } |
1717 | 1763 |
1718 CFWL_EditImpDelegate::CFWL_EditImpDelegate(CFWL_EditImp* pOwner) | 1764 CFWL_EditImpDelegate::CFWL_EditImpDelegate(CFWL_EditImp* pOwner) |
1719 : m_pOwner(pOwner) {} | 1765 : m_pOwner(pOwner) {} |
1720 | 1766 |
1721 int32_t CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | 1767 void CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
1722 if (!pMessage) | 1768 if (!pMessage) |
1723 return 0; | 1769 return; |
1724 | 1770 |
1725 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); | 1771 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); |
1726 int32_t iRet = 1; | |
1727 switch (dwMsgCode) { | 1772 switch (dwMsgCode) { |
1728 case CFWL_MessageType::Activate: { | 1773 case CFWL_MessageType::Activate: { |
1729 DoActivate(static_cast<CFWL_MsgActivate*>(pMessage)); | 1774 DoActivate(static_cast<CFWL_MsgActivate*>(pMessage)); |
1730 break; | 1775 break; |
1731 } | 1776 } |
1732 case CFWL_MessageType::Deactivate: { | 1777 case CFWL_MessageType::Deactivate: { |
1733 DoDeactivate(static_cast<CFWL_MsgDeactivate*>(pMessage)); | 1778 DoDeactivate(static_cast<CFWL_MsgDeactivate*>(pMessage)); |
1734 break; | 1779 break; |
1735 } | 1780 } |
1736 case CFWL_MessageType::SetFocus: | 1781 case CFWL_MessageType::SetFocus: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1768 } | 1813 } |
1769 case CFWL_MessageType::Key: { | 1814 case CFWL_MessageType::Key: { |
1770 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); | 1815 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); |
1771 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) | 1816 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) |
1772 OnKeyDown(pKey); | 1817 OnKeyDown(pKey); |
1773 else if (pKey->m_dwCmd == FWL_KeyCommand::Char) | 1818 else if (pKey->m_dwCmd == FWL_KeyCommand::Char) |
1774 OnChar(pKey); | 1819 OnChar(pKey); |
1775 break; | 1820 break; |
1776 } | 1821 } |
1777 default: { | 1822 default: { |
1778 iRet = 0; | |
1779 break; | 1823 break; |
1780 } | 1824 } |
1781 } | 1825 } |
1782 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); | 1826 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); |
1783 return iRet; | |
1784 } | 1827 } |
1785 | 1828 |
1786 FWL_ERR CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { | 1829 void CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { |
1787 if (!pEvent) | 1830 if (!pEvent) |
1788 return FWL_ERR_Indefinite; | 1831 return; |
1789 if (pEvent->GetClassID() != CFWL_EventType::Scroll) | 1832 if (pEvent->GetClassID() != CFWL_EventType::Scroll) |
1790 return FWL_ERR_Succeeded; | 1833 return; |
1791 | 1834 |
1792 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; | 1835 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; |
1793 if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && | 1836 if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && |
1794 m_pOwner->m_pVertScrollBar) || | 1837 m_pOwner->m_pVertScrollBar) || |
1795 (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && | 1838 (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && |
1796 m_pOwner->m_pHorzScrollBar)) { | 1839 m_pOwner->m_pHorzScrollBar)) { |
1797 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); | 1840 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); |
1798 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget), | 1841 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget), |
1799 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); | 1842 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); |
1800 } | 1843 } |
1801 return FWL_ERR_Succeeded; | |
1802 } | 1844 } |
1803 | 1845 |
1804 FWL_ERR CFWL_EditImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 1846 void CFWL_EditImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
1805 const CFX_Matrix* pMatrix) { | 1847 const CFX_Matrix* pMatrix) { |
1806 return m_pOwner->DrawWidget(pGraphics, pMatrix); | 1848 m_pOwner->DrawWidget(pGraphics, pMatrix); |
1807 } | 1849 } |
| 1850 |
1808 void CFWL_EditImpDelegate::DoActivate(CFWL_MsgActivate* pMsg) { | 1851 void CFWL_EditImpDelegate::DoActivate(CFWL_MsgActivate* pMsg) { |
1809 m_pOwner->m_pProperties->m_dwStates |= ~FWL_WGTSTATE_Deactivated; | 1852 m_pOwner->m_pProperties->m_dwStates |= ~FWL_WGTSTATE_Deactivated; |
1810 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1853 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
1811 } | 1854 } |
1812 void CFWL_EditImpDelegate::DoDeactivate(CFWL_MsgDeactivate* pMsg) { | 1855 void CFWL_EditImpDelegate::DoDeactivate(CFWL_MsgDeactivate* pMsg) { |
1813 m_pOwner->m_pProperties->m_dwStates &= FWL_WGTSTATE_Deactivated; | 1856 m_pOwner->m_pProperties->m_dwStates &= FWL_WGTSTATE_Deactivated; |
1814 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1857 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
1815 } | 1858 } |
1816 void CFWL_EditImpDelegate::DoButtonDown(CFWL_MsgMouse* pMsg) { | 1859 void CFWL_EditImpDelegate::DoButtonDown(CFWL_MsgMouse* pMsg) { |
1817 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { | 1860 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2156 } | 2199 } |
2157 CFX_RectF rect; | 2200 CFX_RectF rect; |
2158 m_pOwner->GetWidgetRect(rect); | 2201 m_pOwner->GetWidgetRect(rect); |
2159 CFX_RectF rtInvalidate; | 2202 CFX_RectF rtInvalidate; |
2160 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); | 2203 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); |
2161 m_pOwner->Repaint(&rtInvalidate); | 2204 m_pOwner->Repaint(&rtInvalidate); |
2162 } | 2205 } |
2163 return TRUE; | 2206 return TRUE; |
2164 } | 2207 } |
2165 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} | 2208 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} |
OLD | NEW |