| 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/core/ifwl_edit.h" | 7 #include "xfa/fwl/core/ifwl_edit.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 IFWL_Edit::IFWL_Edit(const IFWL_App* app, | 55 IFWL_Edit::IFWL_Edit(const IFWL_App* app, |
| 56 std::unique_ptr<CFWL_WidgetProperties> properties, | 56 std::unique_ptr<CFWL_WidgetProperties> properties, |
| 57 IFWL_Widget* pOuter) | 57 IFWL_Widget* pOuter) |
| 58 : IFWL_Widget(app, std::move(properties), pOuter), | 58 : IFWL_Widget(app, std::move(properties), pOuter), |
| 59 m_fVAlignOffset(0.0f), | 59 m_fVAlignOffset(0.0f), |
| 60 m_fScrollOffsetX(0.0f), | 60 m_fScrollOffsetX(0.0f), |
| 61 m_fScrollOffsetY(0.0f), | 61 m_fScrollOffsetY(0.0f), |
| 62 m_bLButtonDown(false), | 62 m_bLButtonDown(false), |
| 63 m_nSelStart(0), | 63 m_nSelStart(0), |
| 64 m_nLimit(-1), | 64 m_nLimit(-1), |
| 65 m_fSpaceAbove(0), | |
| 66 m_fSpaceBelow(0), | |
| 67 m_fFontSize(0), | 65 m_fFontSize(0), |
| 68 m_bSetRange(false), | 66 m_bSetRange(false), |
| 69 m_iMin(-1), | |
| 70 m_iMax(0xFFFFFFF), | 67 m_iMax(0xFFFFFFF), |
| 71 m_backColor(0), | |
| 72 m_updateBackColor(false), | |
| 73 m_iCurRecord(-1), | 68 m_iCurRecord(-1), |
| 74 m_iMaxRecord(128) { | 69 m_iMaxRecord(128) { |
| 75 m_rtClient.Reset(); | 70 m_rtClient.Reset(); |
| 76 m_rtEngine.Reset(); | 71 m_rtEngine.Reset(); |
| 77 m_rtStatic.Reset(); | 72 m_rtStatic.Reset(); |
| 78 | 73 |
| 79 InitCaret(); | 74 InitCaret(); |
| 80 if (!m_pEdtEngine) | |
| 81 InitEngine(); | |
| 82 } | 75 } |
| 83 | 76 |
| 84 IFWL_Edit::~IFWL_Edit() { | 77 IFWL_Edit::~IFWL_Edit() { |
| 85 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) | 78 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) |
| 86 ShowCaret(false); | 79 ShowCaret(false); |
| 87 | 80 |
| 88 ClearRecord(); | 81 ClearRecord(); |
| 89 } | 82 } |
| 90 | 83 |
| 91 FWL_Type IFWL_Edit::GetClassID() const { | 84 FWL_Type IFWL_Edit::GetClassID() const { |
| 92 return FWL_Type::Edit; | 85 return FWL_Type::Edit; |
| 93 } | 86 } |
| 94 | 87 |
| 95 void IFWL_Edit::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { | 88 void IFWL_Edit::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { |
| 96 if (bAutoSize) { | 89 if (bAutoSize) { |
| 97 rect.Set(0, 0, 0, 0); | 90 rect.Set(0, 0, 0, 0); |
| 98 if (m_pEdtEngine) { | 91 |
| 99 int32_t iTextLen = m_pEdtEngine->GetTextLength(); | 92 int32_t iTextLen = m_EdtEngine.GetTextLength(); |
| 100 if (iTextLen > 0) { | 93 if (iTextLen > 0) { |
| 101 CFX_WideString wsText; | 94 CFX_WideString wsText; |
| 102 m_pEdtEngine->GetText(wsText, 0); | 95 m_EdtEngine.GetText(wsText, 0); |
| 103 CFX_SizeF sz = CalcTextSize( | 96 CFX_SizeF sz = CalcTextSize( |
| 104 wsText, m_pProperties->m_pThemeProvider, | 97 wsText, m_pProperties->m_pThemeProvider, |
| 105 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine)); | 98 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine)); |
| 106 rect.Set(0, 0, sz.x, sz.y); | 99 rect.Set(0, 0, sz.x, sz.y); |
| 107 } | |
| 108 } | 100 } |
| 109 IFWL_Widget::GetWidgetRect(rect, true); | 101 IFWL_Widget::GetWidgetRect(rect, true); |
| 110 } else { | 102 } else { |
| 111 rect = m_pProperties->m_rtWidget; | 103 rect = m_pProperties->m_rtWidget; |
| 112 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { | 104 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { |
| 113 if (IsShowScrollBar(true)) { | 105 if (IsShowScrollBar(true)) { |
| 114 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( | 106 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( |
| 115 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); | 107 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
| 116 rect.width += *pfWidth; | 108 rect.width += *pfWidth; |
| 117 rect.width += kEditMargin; | 109 rect.width += kEditMargin; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 165 |
| 174 void IFWL_Edit::AddSpellCheckObj(CFX_Path& PathData, | 166 void IFWL_Edit::AddSpellCheckObj(CFX_Path& PathData, |
| 175 int32_t nStart, | 167 int32_t nStart, |
| 176 int32_t nCount, | 168 int32_t nCount, |
| 177 FX_FLOAT fOffSetX, | 169 FX_FLOAT fOffSetX, |
| 178 FX_FLOAT fOffSetY) { | 170 FX_FLOAT fOffSetY) { |
| 179 FX_FLOAT fStartX = 0.0f; | 171 FX_FLOAT fStartX = 0.0f; |
| 180 FX_FLOAT fEndX = 0.0f; | 172 FX_FLOAT fEndX = 0.0f; |
| 181 FX_FLOAT fY = 0.0f; | 173 FX_FLOAT fY = 0.0f; |
| 182 FX_FLOAT fStep = 0.0f; | 174 FX_FLOAT fStep = 0.0f; |
| 183 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); | 175 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); |
| 184 CFX_RectFArray rectArray; | 176 CFX_RectFArray rectArray; |
| 185 CFX_RectF rectText; | 177 CFX_RectF rectText; |
| 186 const FDE_TXTEDTPARAMS* txtEdtParams = m_pEdtEngine->GetEditParams(); | 178 const FDE_TXTEDTPARAMS* txtEdtParams = m_EdtEngine.GetEditParams(); |
| 187 FX_FLOAT fAsent = (FX_FLOAT)txtEdtParams->pFont->GetAscent() * | 179 FX_FLOAT fAsent = (FX_FLOAT)txtEdtParams->pFont->GetAscent() * |
| 188 txtEdtParams->fFontSize / 1000; | 180 txtEdtParams->fFontSize / 1000; |
| 189 pPage->CalcRangeRectArray(nStart, nCount, rectArray); | 181 pPage->CalcRangeRectArray(nStart, nCount, rectArray); |
| 190 for (int i = 0; i < rectArray.GetSize(); i++) { | 182 for (int i = 0; i < rectArray.GetSize(); i++) { |
| 191 rectText = rectArray.GetAt(i); | 183 rectText = rectArray.GetAt(i); |
| 192 fY = rectText.top + fAsent + fOffSetY; | 184 fY = rectText.top + fAsent + fOffSetY; |
| 193 fStep = txtEdtParams->fFontSize / 16.0f; | 185 fStep = txtEdtParams->fFontSize / 16.0f; |
| 194 fStartX = rectText.left + fOffSetX; | 186 fStartX = rectText.left + fOffSetX; |
| 195 fEndX = fStartX + rectText.Width(); | 187 fEndX = fStartX + rectText.Width(); |
| 196 AddSquigglyPath(&PathData, fStartX, fEndX, fY, fStep); | 188 AddSquigglyPath(&PathData, fStartX, fEndX, fY, fStep); |
| 197 } | 189 } |
| 198 } | 190 } |
| 199 int32_t IFWL_Edit::GetWordAtPoint(CFX_PointF pointf, int32_t& nCount) { | |
| 200 return 0; | |
| 201 } | |
| 202 bool IFWL_Edit::GetSuggestWords(CFX_PointF pointf, | |
| 203 std::vector<CFX_ByteString>& sSuggest) { | |
| 204 int32_t nWordCount = 0; | |
| 205 int32_t nWordStart = GetWordAtPoint(pointf, nWordCount); | |
| 206 if (nWordCount < 1) { | |
| 207 return false; | |
| 208 } | |
| 209 CFX_WideString wsSpell; | |
| 210 GetText(wsSpell, nWordStart, nWordCount); | |
| 211 CFX_ByteString sLatinWord; | |
| 212 for (int i = 0; i < nWordCount; i++) { | |
| 213 if (!FX_EDIT_ISLATINWORD(wsSpell[i])) { | |
| 214 break; | |
| 215 } | |
| 216 sLatinWord += (FX_CHAR)wsSpell[i]; | |
| 217 } | |
| 218 if (sLatinWord.IsEmpty()) { | |
| 219 return false; | |
| 220 } | |
| 221 CFWL_EvtEdtCheckWord checkWordEvent; | |
| 222 checkWordEvent.m_pSrcTarget = this; | |
| 223 checkWordEvent.bsWord = sLatinWord; | |
| 224 checkWordEvent.bCheckWord = true; | |
| 225 DispatchEvent(&checkWordEvent); | |
| 226 if (checkWordEvent.bCheckWord) { | |
| 227 return false; | |
| 228 } | |
| 229 CFWL_EvtEdtGetSuggestWords suggestWordsEvent; | |
| 230 suggestWordsEvent.m_pSrcTarget = this; | |
| 231 suggestWordsEvent.bsWord = sLatinWord; | |
| 232 suggestWordsEvent.bsArraySuggestWords = sSuggest; | |
| 233 suggestWordsEvent.bSuggestWords = false; | |
| 234 DispatchEvent(&checkWordEvent); | |
| 235 return suggestWordsEvent.bSuggestWords; | |
| 236 } | |
| 237 bool IFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, | |
| 238 const CFX_ByteStringC& bsReplace) { | |
| 239 int32_t nWordCount = 0; | |
| 240 int32_t nWordStart = GetWordAtPoint(pointf, nWordCount); | |
| 241 if (nWordCount < 1) { | |
| 242 return false; | |
| 243 } | |
| 244 CFX_WideString wsSpell; | |
| 245 GetText(wsSpell, nWordStart, nWordCount); | |
| 246 for (int i = 0; i < nWordCount; i++) { | |
| 247 if (!FX_EDIT_ISLATINWORD(wsSpell[i])) { | |
| 248 nWordCount = i; | |
| 249 break; | |
| 250 } | |
| 251 } | |
| 252 int32_t nDestLen = bsReplace.GetLength(); | |
| 253 CFX_WideString wsDest; | |
| 254 FX_WCHAR* pBuffer = wsDest.GetBuffer(nDestLen); | |
| 255 for (int32_t i = 0; i < nDestLen; i++) { | |
| 256 pBuffer[i] = bsReplace[i]; | |
| 257 } | |
| 258 wsDest.ReleaseBuffer(nDestLen); | |
| 259 Replace(nWordStart, nWordCount, wsDest.AsStringC()); | |
| 260 return true; | |
| 261 } | |
| 262 void IFWL_Edit::DrawSpellCheck(CFX_Graphics* pGraphics, | 191 void IFWL_Edit::DrawSpellCheck(CFX_Graphics* pGraphics, |
| 263 const CFX_Matrix* pMatrix) { | 192 const CFX_Matrix* pMatrix) { |
| 264 pGraphics->SaveGraphState(); | 193 pGraphics->SaveGraphState(); |
| 265 if (pMatrix) { | 194 if (pMatrix) { |
| 266 pGraphics->ConcatMatrix(const_cast<CFX_Matrix*>(pMatrix)); | 195 pGraphics->ConcatMatrix(const_cast<CFX_Matrix*>(pMatrix)); |
| 267 } | 196 } |
| 268 FX_ARGB cr = 0xFFFF0000; | 197 FX_ARGB cr = 0xFFFF0000; |
| 269 CFX_Color crLine(cr); | 198 CFX_Color crLine(cr); |
| 270 CFWL_EvtEdtCheckWord checkWordEvent; | 199 CFWL_EvtEdtCheckWord checkWordEvent; |
| 271 checkWordEvent.m_pSrcTarget = this; | 200 checkWordEvent.m_pSrcTarget = this; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 return; | 251 return; |
| 323 if (!m_pProperties->m_pThemeProvider) | 252 if (!m_pProperties->m_pThemeProvider) |
| 324 return; | 253 return; |
| 325 if (m_rtClient.IsEmpty()) { | 254 if (m_rtClient.IsEmpty()) { |
| 326 return; | 255 return; |
| 327 } | 256 } |
| 328 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 257 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
| 329 if (!m_pWidgetMgr->IsFormDisabled()) { | 258 if (!m_pWidgetMgr->IsFormDisabled()) { |
| 330 DrawTextBk(pGraphics, pTheme, pMatrix); | 259 DrawTextBk(pGraphics, pTheme, pMatrix); |
| 331 } | 260 } |
| 332 if (m_pEdtEngine) { | 261 |
| 333 DrawContent(pGraphics, pTheme, pMatrix); | 262 DrawContent(pGraphics, pTheme, pMatrix); |
| 334 } | 263 |
| 335 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && | 264 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && |
| 336 !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)) { | 265 !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)) { |
| 337 DrawSpellCheck(pGraphics, pMatrix); | 266 DrawSpellCheck(pGraphics, pMatrix); |
| 338 } | 267 } |
| 339 if (HasBorder()) { | 268 if (HasBorder()) { |
| 340 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); | 269 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); |
| 341 } | 270 } |
| 342 if (HasEdge()) { | 271 if (HasEdge()) { |
| 343 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 272 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
| 344 } | 273 } |
| 345 } | 274 } |
| 346 void IFWL_Edit::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | 275 void IFWL_Edit::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { |
| 347 if (!pThemeProvider) | 276 if (!pThemeProvider) |
| 348 return; | 277 return; |
| 349 if (m_pHorzScrollBar) { | 278 if (m_pHorzScrollBar) { |
| 350 m_pHorzScrollBar->SetThemeProvider(pThemeProvider); | 279 m_pHorzScrollBar->SetThemeProvider(pThemeProvider); |
| 351 } | 280 } |
| 352 if (m_pVertScrollBar) { | 281 if (m_pVertScrollBar) { |
| 353 m_pVertScrollBar->SetThemeProvider(pThemeProvider); | 282 m_pVertScrollBar->SetThemeProvider(pThemeProvider); |
| 354 } | 283 } |
| 355 if (m_pCaret) { | 284 if (m_pCaret) { |
| 356 m_pCaret->SetThemeProvider(pThemeProvider); | 285 m_pCaret->SetThemeProvider(pThemeProvider); |
| 357 } | 286 } |
| 358 m_pProperties->m_pThemeProvider = pThemeProvider; | 287 m_pProperties->m_pThemeProvider = pThemeProvider; |
| 359 } | 288 } |
| 360 | 289 |
| 361 FWL_Error IFWL_Edit::SetText(const CFX_WideString& wsText) { | 290 void IFWL_Edit::SetText(const CFX_WideString& wsText) { |
| 362 m_pEdtEngine->SetText(wsText); | 291 m_EdtEngine.SetText(wsText); |
| 363 return FWL_Error::Succeeded; | |
| 364 } | 292 } |
| 365 | 293 |
| 366 int32_t IFWL_Edit::GetTextLength() const { | 294 int32_t IFWL_Edit::GetTextLength() const { |
| 367 if (!m_pEdtEngine) | 295 return m_EdtEngine.GetTextLength(); |
| 368 return -1; | |
| 369 return m_pEdtEngine->GetTextLength(); | |
| 370 } | 296 } |
| 371 | 297 |
| 372 FWL_Error IFWL_Edit::GetText(CFX_WideString& wsText, | 298 void IFWL_Edit::GetText(CFX_WideString& wsText, |
| 373 int32_t nStart, | 299 int32_t nStart, |
| 374 int32_t nCount) const { | 300 int32_t nCount) { |
| 375 if (!m_pEdtEngine) | 301 m_EdtEngine.GetText(wsText, nStart, nCount); |
| 376 return FWL_Error::Indefinite; | |
| 377 | |
| 378 m_pEdtEngine->GetText(wsText, nStart, nCount); | |
| 379 return FWL_Error::Succeeded; | |
| 380 } | 302 } |
| 381 | 303 |
| 382 FWL_Error IFWL_Edit::ClearText() { | 304 void IFWL_Edit::ClearText() { |
| 383 if (!m_pEdtEngine) | 305 m_EdtEngine.ClearText(); |
| 384 return FWL_Error::Indefinite; | |
| 385 | |
| 386 m_pEdtEngine->ClearText(); | |
| 387 return FWL_Error::Succeeded; | |
| 388 } | 306 } |
| 389 | 307 |
| 390 int32_t IFWL_Edit::GetCaretPos() const { | 308 void IFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { |
| 391 if (!m_pEdtEngine) | 309 m_EdtEngine.AddSelRange(nStart, nCount); |
| 392 return -1; | |
| 393 return m_pEdtEngine->GetCaretPos(); | |
| 394 } | |
| 395 | |
| 396 int32_t IFWL_Edit::SetCaretPos(int32_t nIndex, bool bBefore) { | |
| 397 if (!m_pEdtEngine) | |
| 398 return -1; | |
| 399 return m_pEdtEngine->SetCaretPos(nIndex, bBefore); | |
| 400 } | |
| 401 | |
| 402 FWL_Error IFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { | |
| 403 if (!m_pEdtEngine) | |
| 404 return FWL_Error::Indefinite; | |
| 405 | |
| 406 m_pEdtEngine->AddSelRange(nStart, nCount); | |
| 407 return FWL_Error::Succeeded; | |
| 408 } | 310 } |
| 409 | 311 |
| 410 int32_t IFWL_Edit::CountSelRanges() { | 312 int32_t IFWL_Edit::CountSelRanges() { |
| 411 if (!m_pEdtEngine) | 313 return m_EdtEngine.CountSelRanges(); |
| 412 return 0; | |
| 413 return m_pEdtEngine->CountSelRanges(); | |
| 414 } | 314 } |
| 415 | 315 |
| 416 int32_t IFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { | 316 int32_t IFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { |
| 417 if (!m_pEdtEngine) | 317 return m_EdtEngine.GetSelRange(nIndex, nStart); |
| 418 return -1; | |
| 419 return m_pEdtEngine->GetSelRange(nIndex, nStart); | |
| 420 } | 318 } |
| 421 | 319 |
| 422 FWL_Error IFWL_Edit::ClearSelections() { | 320 void IFWL_Edit::ClearSelections() { |
| 423 if (!m_pEdtEngine) | 321 m_EdtEngine.ClearSelection(); |
| 424 return FWL_Error::Indefinite; | |
| 425 | |
| 426 m_pEdtEngine->ClearSelection(); | |
| 427 return FWL_Error::Succeeded; | |
| 428 } | 322 } |
| 429 | 323 |
| 430 int32_t IFWL_Edit::GetLimit() { | 324 int32_t IFWL_Edit::GetLimit() { |
| 431 return m_nLimit; | 325 return m_nLimit; |
| 432 } | 326 } |
| 433 | 327 |
| 434 FWL_Error IFWL_Edit::SetLimit(int32_t nLimit) { | 328 void IFWL_Edit::SetLimit(int32_t nLimit) { |
| 435 m_nLimit = nLimit; | 329 m_nLimit = nLimit; |
| 436 if (!m_pEdtEngine) | 330 m_EdtEngine.SetLimit(nLimit); |
| 437 return FWL_Error::Indefinite; | |
| 438 | |
| 439 m_pEdtEngine->SetLimit(nLimit); | |
| 440 return FWL_Error::Succeeded; | |
| 441 } | 331 } |
| 442 | 332 |
| 443 FWL_Error IFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { | 333 void IFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { |
| 444 if (!m_pEdtEngine) | 334 m_EdtEngine.SetAliasChar(wAlias); |
| 445 return FWL_Error::Indefinite; | |
| 446 | |
| 447 m_pEdtEngine->SetAliasChar(wAlias); | |
| 448 return FWL_Error::Succeeded; | |
| 449 } | |
| 450 | |
| 451 FWL_Error IFWL_Edit::Insert(int32_t nStart, | |
| 452 const FX_WCHAR* lpText, | |
| 453 int32_t nLen) { | |
| 454 if (!m_pEdtEngine) | |
| 455 return FWL_Error::Indefinite; | |
| 456 | |
| 457 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || | |
| 458 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { | |
| 459 return FWL_Error::Indefinite; | |
| 460 } | |
| 461 m_pEdtEngine->Insert(nStart, lpText, nLen); | |
| 462 return FWL_Error::Succeeded; | |
| 463 } | |
| 464 | |
| 465 FWL_Error IFWL_Edit::DeleteSelections() { | |
| 466 if (!m_pEdtEngine) | |
| 467 return FWL_Error::Indefinite; | |
| 468 | |
| 469 int32_t iCount = m_pEdtEngine->CountSelRanges(); | |
| 470 if (iCount > 0) | |
| 471 m_pEdtEngine->Delete(-1); | |
| 472 return FWL_Error::Succeeded; | |
| 473 } | |
| 474 | |
| 475 FWL_Error IFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) { | |
| 476 if (!m_pEdtEngine) | |
| 477 return FWL_Error::Indefinite; | |
| 478 | |
| 479 m_pEdtEngine->DeleteRange(nStart, nCount); | |
| 480 return FWL_Error::Succeeded; | |
| 481 } | |
| 482 | |
| 483 FWL_Error IFWL_Edit::Replace(int32_t nStart, | |
| 484 int32_t nLen, | |
| 485 const CFX_WideStringC& wsReplace) { | |
| 486 if (!m_pEdtEngine) | |
| 487 return FWL_Error::Indefinite; | |
| 488 | |
| 489 m_pEdtEngine->Replace(nStart, nLen, CFX_WideString(wsReplace)); | |
| 490 return FWL_Error::Succeeded; | |
| 491 } | |
| 492 | |
| 493 FWL_Error IFWL_Edit::DoClipboard(int32_t iCmd) { | |
| 494 if (!m_pEdtEngine) | |
| 495 return FWL_Error::Indefinite; | |
| 496 | |
| 497 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || | |
| 498 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { | |
| 499 return FWL_Error::Succeeded; | |
| 500 } | |
| 501 return FWL_Error::Indefinite; | |
| 502 } | 335 } |
| 503 | 336 |
| 504 bool IFWL_Edit::Copy(CFX_WideString& wsCopy) { | 337 bool IFWL_Edit::Copy(CFX_WideString& wsCopy) { |
| 505 if (!m_pEdtEngine) | 338 int32_t nCount = m_EdtEngine.CountSelRanges(); |
| 506 return false; | |
| 507 | |
| 508 int32_t nCount = m_pEdtEngine->CountSelRanges(); | |
| 509 if (nCount == 0) | 339 if (nCount == 0) |
| 510 return false; | 340 return false; |
| 511 | 341 |
| 512 wsCopy.clear(); | 342 wsCopy.clear(); |
| 513 CFX_WideString wsTemp; | 343 CFX_WideString wsTemp; |
| 514 int32_t nStart, nLength; | 344 int32_t nStart, nLength; |
| 515 for (int32_t i = 0; i < nCount; i++) { | 345 for (int32_t i = 0; i < nCount; i++) { |
| 516 nLength = m_pEdtEngine->GetSelRange(i, nStart); | 346 nLength = m_EdtEngine.GetSelRange(i, nStart); |
| 517 m_pEdtEngine->GetText(wsTemp, nStart, nLength); | 347 m_EdtEngine.GetText(wsTemp, nStart, nLength); |
| 518 wsCopy += wsTemp; | 348 wsCopy += wsTemp; |
| 519 wsTemp.clear(); | 349 wsTemp.clear(); |
| 520 } | 350 } |
| 521 return true; | 351 return true; |
| 522 } | 352 } |
| 523 | 353 |
| 524 bool IFWL_Edit::Cut(CFX_WideString& wsCut) { | 354 bool IFWL_Edit::Cut(CFX_WideString& wsCut) { |
| 525 if (!m_pEdtEngine) | 355 int32_t nCount = m_EdtEngine.CountSelRanges(); |
| 526 return false; | |
| 527 | |
| 528 int32_t nCount = m_pEdtEngine->CountSelRanges(); | |
| 529 if (nCount == 0) | 356 if (nCount == 0) |
| 530 return false; | 357 return false; |
| 531 | 358 |
| 532 wsCut.clear(); | 359 wsCut.clear(); |
| 533 CFX_WideString wsTemp; | 360 CFX_WideString wsTemp; |
| 534 int32_t nStart, nLength; | 361 int32_t nStart, nLength; |
| 535 for (int32_t i = 0; i < nCount; i++) { | 362 for (int32_t i = 0; i < nCount; i++) { |
| 536 nLength = m_pEdtEngine->GetSelRange(i, nStart); | 363 nLength = m_EdtEngine.GetSelRange(i, nStart); |
| 537 m_pEdtEngine->GetText(wsTemp, nStart, nLength); | 364 m_EdtEngine.GetText(wsTemp, nStart, nLength); |
| 538 wsCut += wsTemp; | 365 wsCut += wsTemp; |
| 539 wsTemp.clear(); | 366 wsTemp.clear(); |
| 540 } | 367 } |
| 541 m_pEdtEngine->Delete(0); | 368 m_EdtEngine.Delete(0); |
| 542 return true; | 369 return true; |
| 543 } | 370 } |
| 544 | 371 |
| 545 bool IFWL_Edit::Paste(const CFX_WideString& wsPaste) { | 372 bool IFWL_Edit::Paste(const CFX_WideString& wsPaste) { |
| 546 if (!m_pEdtEngine) | 373 int32_t nCaret = m_EdtEngine.GetCaretPos(); |
| 547 return false; | |
| 548 | |
| 549 int32_t nCaret = m_pEdtEngine->GetCaretPos(); | |
| 550 int32_t iError = | 374 int32_t iError = |
| 551 m_pEdtEngine->Insert(nCaret, wsPaste.c_str(), wsPaste.GetLength()); | 375 m_EdtEngine.Insert(nCaret, wsPaste.c_str(), wsPaste.GetLength()); |
| 552 if (iError < 0) { | 376 if (iError < 0) { |
| 553 ProcessInsertError(iError); | 377 ProcessInsertError(iError); |
| 554 return false; | 378 return false; |
| 555 } | 379 } |
| 556 return true; | 380 return true; |
| 557 } | 381 } |
| 558 | 382 |
| 559 bool IFWL_Edit::Delete() { | |
| 560 if (!m_pEdtEngine) | |
| 561 return false; | |
| 562 | |
| 563 int32_t nCount = m_pEdtEngine->CountSelRanges(); | |
| 564 if (nCount < 1) | |
| 565 return false; | |
| 566 | |
| 567 m_pEdtEngine->Delete(0); | |
| 568 return true; | |
| 569 } | |
| 570 | |
| 571 bool IFWL_Edit::Redo(const IFDE_TxtEdtDoRecord* pRecord) { | 383 bool IFWL_Edit::Redo(const IFDE_TxtEdtDoRecord* pRecord) { |
| 572 if (!m_pEdtEngine) | |
| 573 return false; | |
| 574 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) | 384 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) |
| 575 return true; | 385 return true; |
| 576 return m_pEdtEngine->Redo(pRecord); | 386 return m_EdtEngine.Redo(pRecord); |
| 577 } | 387 } |
| 578 | 388 |
| 579 bool IFWL_Edit::Undo(const IFDE_TxtEdtDoRecord* pRecord) { | 389 bool IFWL_Edit::Undo(const IFDE_TxtEdtDoRecord* pRecord) { |
| 580 if (!m_pEdtEngine) | |
| 581 return false; | |
| 582 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) | 390 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) |
| 583 return true; | 391 return true; |
| 584 return m_pEdtEngine->Undo(pRecord); | 392 return m_EdtEngine.Undo(pRecord); |
| 585 } | 393 } |
| 586 | 394 |
| 587 bool IFWL_Edit::Undo() { | 395 bool IFWL_Edit::Undo() { |
| 588 if (!CanUndo()) | 396 if (!CanUndo()) |
| 589 return false; | 397 return false; |
| 590 return Undo(m_DoRecords[m_iCurRecord--].get()); | 398 return Undo(m_DoRecords[m_iCurRecord--].get()); |
| 591 } | 399 } |
| 592 | 400 |
| 593 bool IFWL_Edit::Redo() { | 401 bool IFWL_Edit::Redo() { |
| 594 if (!CanRedo()) | 402 if (!CanRedo()) |
| 595 return false; | 403 return false; |
| 596 return Redo(m_DoRecords[++m_iCurRecord].get()); | 404 return Redo(m_DoRecords[++m_iCurRecord].get()); |
| 597 } | 405 } |
| 598 | 406 |
| 599 bool IFWL_Edit::CanUndo() { | 407 bool IFWL_Edit::CanUndo() { |
| 600 return m_iCurRecord >= 0; | 408 return m_iCurRecord >= 0; |
| 601 } | 409 } |
| 602 | 410 |
| 603 bool IFWL_Edit::CanRedo() { | 411 bool IFWL_Edit::CanRedo() { |
| 604 return m_iCurRecord < pdfium::CollectionSize<int32_t>(m_DoRecords) - 1; | 412 return m_iCurRecord < pdfium::CollectionSize<int32_t>(m_DoRecords) - 1; |
| 605 } | 413 } |
| 606 | 414 |
| 607 FWL_Error IFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, bool bEquidistant) { | 415 void IFWL_Edit::SetOuter(IFWL_Widget* pOuter) { |
| 608 if (!m_pEdtEngine) | |
| 609 return FWL_Error::Indefinite; | |
| 610 | |
| 611 FDE_TXTEDTPARAMS* pParams = m_pEdtEngine->GetEditParams(); | |
| 612 pParams->fTabWidth = fTabWidth; | |
| 613 pParams->bTabEquidistant = bEquidistant; | |
| 614 return FWL_Error::Succeeded; | |
| 615 } | |
| 616 | |
| 617 FWL_Error IFWL_Edit::SetOuter(IFWL_Widget* pOuter) { | |
| 618 m_pOuter = pOuter; | 416 m_pOuter = pOuter; |
| 619 return FWL_Error::Succeeded; | |
| 620 } | |
| 621 | |
| 622 FWL_Error IFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { | |
| 623 m_iMin = iMin; | |
| 624 m_iMax = iMax; | |
| 625 m_bSetRange = true; | |
| 626 return FWL_Error::Succeeded; | |
| 627 } | 417 } |
| 628 | 418 |
| 629 void IFWL_Edit::On_CaretChanged(CFDE_TxtEdtEngine* pEdit, | 419 void IFWL_Edit::On_CaretChanged(CFDE_TxtEdtEngine* pEdit, |
| 630 int32_t nPage, | 420 int32_t nPage, |
| 631 bool bVisible) { | 421 bool bVisible) { |
| 632 if (m_rtEngine.IsEmpty()) | 422 if (m_rtEngine.IsEmpty()) |
| 633 return; | 423 return; |
| 634 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) | 424 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) |
| 635 return; | 425 return; |
| 636 | 426 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 653 Repaint(&rtInvalid); | 443 Repaint(&rtInvalid); |
| 654 } | 444 } |
| 655 } | 445 } |
| 656 | 446 |
| 657 void IFWL_Edit::On_TextChanged(CFDE_TxtEdtEngine* pEdit, | 447 void IFWL_Edit::On_TextChanged(CFDE_TxtEdtEngine* pEdit, |
| 658 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { | 448 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { |
| 659 uint32_t dwStyleEx = m_pProperties->m_dwStyleExes; | 449 uint32_t dwStyleEx = m_pProperties->m_dwStyleExes; |
| 660 if (dwStyleEx & FWL_STYLEEXT_EDT_VAlignMask) | 450 if (dwStyleEx & FWL_STYLEEXT_EDT_VAlignMask) |
| 661 UpdateVAlignment(); | 451 UpdateVAlignment(); |
| 662 | 452 |
| 663 IFDE_TxtEdtPage* page = m_pEdtEngine->GetPage(0); | 453 IFDE_TxtEdtPage* page = m_EdtEngine.GetPage(0); |
| 664 FX_FLOAT fContentWidth = page->GetContentsBox().width; | 454 FX_FLOAT fContentWidth = page->GetContentsBox().width; |
| 665 FX_FLOAT fContentHeight = page->GetContentsBox().height; | 455 FX_FLOAT fContentHeight = page->GetContentsBox().height; |
| 666 CFX_RectF rtTemp; | 456 CFX_RectF rtTemp; |
| 667 GetClientRect(rtTemp); | 457 GetClientRect(rtTemp); |
| 668 bool bHSelfAdaption = | 458 bool bHSelfAdaption = |
| 669 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption); | 459 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption); |
| 670 bool bVSelfAdaption = | 460 bool bVSelfAdaption = |
| 671 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption); | 461 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption); |
| 672 bool bNeedUpdate = false; | 462 bool bNeedUpdate = false; |
| 673 if (bHSelfAdaption || bVSelfAdaption) { | 463 if (bHSelfAdaption || bVSelfAdaption) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 690 0, FWL_STYLEEXT_EDT_VSelfAdaption | FWL_STYLEEXT_EDT_AutoVScroll); | 480 0, FWL_STYLEEXT_EDT_VSelfAdaption | FWL_STYLEEXT_EDT_AutoVScroll); |
| 691 } | 481 } |
| 692 bNeedUpdate = (bHSelfAdaption && !evt.bHSelfAdaption) || | 482 bNeedUpdate = (bHSelfAdaption && !evt.bHSelfAdaption) || |
| 693 (bVSelfAdaption && !evt.bVSelfAdaption); | 483 (bVSelfAdaption && !evt.bVSelfAdaption); |
| 694 } | 484 } |
| 695 FX_FLOAT fContentWidth1 = fContentWidth; | 485 FX_FLOAT fContentWidth1 = fContentWidth; |
| 696 FX_FLOAT fContentHeight1 = fContentHeight; | 486 FX_FLOAT fContentHeight1 = fContentHeight; |
| 697 if (bNeedUpdate) { | 487 if (bNeedUpdate) { |
| 698 UpdateEditParams(); | 488 UpdateEditParams(); |
| 699 UpdateEditLayout(); | 489 UpdateEditLayout(); |
| 700 IFDE_TxtEdtPage* page1 = m_pEdtEngine->GetPage(0); | 490 IFDE_TxtEdtPage* page1 = m_EdtEngine.GetPage(0); |
| 701 fContentWidth1 = page1->GetContentsBox().width; | 491 fContentWidth1 = page1->GetContentsBox().width; |
| 702 fContentHeight1 = page1->GetContentsBox().height; | 492 fContentHeight1 = page1->GetContentsBox().height; |
| 703 } | 493 } |
| 704 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption) { | 494 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption) { |
| 705 rtTemp.width = std::max(m_pProperties->m_rtWidget.width, fContentWidth1); | 495 rtTemp.width = std::max(m_pProperties->m_rtWidget.width, fContentWidth1); |
| 706 m_pProperties->m_rtWidget.width = fContentWidth1; | 496 m_pProperties->m_rtWidget.width = fContentWidth1; |
| 707 } | 497 } |
| 708 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption) { | 498 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption) { |
| 709 rtTemp.height = std::max(m_pProperties->m_rtWidget.height, fContentHeight1); | 499 rtTemp.height = std::max(m_pProperties->m_rtWidget.height, fContentHeight1); |
| 710 m_pProperties->m_rtWidget.height = fContentHeight1; | 500 m_pProperties->m_rtWidget.height = fContentHeight1; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 722 | 512 |
| 723 void IFWL_Edit::On_SelChanged(CFDE_TxtEdtEngine* pEdit) { | 513 void IFWL_Edit::On_SelChanged(CFDE_TxtEdtEngine* pEdit) { |
| 724 CFX_RectF rtTemp; | 514 CFX_RectF rtTemp; |
| 725 GetClientRect(rtTemp); | 515 GetClientRect(rtTemp); |
| 726 Repaint(&rtTemp); | 516 Repaint(&rtTemp); |
| 727 } | 517 } |
| 728 | 518 |
| 729 bool IFWL_Edit::On_PageLoad(CFDE_TxtEdtEngine* pEdit, | 519 bool IFWL_Edit::On_PageLoad(CFDE_TxtEdtEngine* pEdit, |
| 730 int32_t nPageIndex, | 520 int32_t nPageIndex, |
| 731 int32_t nPurpose) { | 521 int32_t nPurpose) { |
| 732 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(nPageIndex); | 522 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex); |
| 733 if (!pPage) | 523 if (!pPage) |
| 734 return false; | 524 return false; |
| 735 pPage->LoadPage(nullptr, nullptr); | 525 pPage->LoadPage(nullptr, nullptr); |
| 736 return true; | 526 return true; |
| 737 } | 527 } |
| 738 | 528 |
| 739 bool IFWL_Edit::On_PageUnload(CFDE_TxtEdtEngine* pEdit, | 529 bool IFWL_Edit::On_PageUnload(CFDE_TxtEdtEngine* pEdit, |
| 740 int32_t nPageIndex, | 530 int32_t nPageIndex, |
| 741 int32_t nPurpose) { | 531 int32_t nPurpose) { |
| 742 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(nPageIndex); | 532 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex); |
| 743 if (!pPage) | 533 if (!pPage) |
| 744 return false; | 534 return false; |
| 745 pPage->UnloadPage(nullptr); | 535 pPage->UnloadPage(nullptr); |
| 746 return true; | 536 return true; |
| 747 } | 537 } |
| 748 | 538 |
| 749 void IFWL_Edit::On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, | 539 void IFWL_Edit::On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, |
| 750 IFDE_TxtEdtDoRecord* pRecord) { | 540 IFDE_TxtEdtDoRecord* pRecord) { |
| 751 AddDoRecord(pRecord); | 541 AddDoRecord(pRecord); |
| 752 } | 542 } |
| 753 | 543 |
| 754 bool IFWL_Edit::On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText) { | 544 bool IFWL_Edit::On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText) { |
| 755 IFWL_Widget* pDst = GetOuter(); | 545 IFWL_Widget* pDst = GetOuter(); |
| 756 if (!pDst) { | 546 if (!pDst) { |
| 757 pDst = this; | 547 pDst = this; |
| 758 } | 548 } |
| 759 CFWL_EvtEdtValidate event; | 549 CFWL_EvtEdtValidate event; |
| 760 event.pDstWidget = pDst; | 550 event.pDstWidget = pDst; |
| 761 event.m_pSrcTarget = this; | 551 event.m_pSrcTarget = this; |
| 762 event.wsInsert = wsText; | 552 event.wsInsert = wsText; |
| 763 event.bValidate = true; | 553 event.bValidate = true; |
| 764 DispatchEvent(&event); | 554 DispatchEvent(&event); |
| 765 return event.bValidate; | 555 return event.bValidate; |
| 766 } | 556 } |
| 767 | 557 |
| 768 FWL_Error IFWL_Edit::SetBackgroundColor(uint32_t color) { | |
| 769 m_backColor = color; | |
| 770 m_updateBackColor = true; | |
| 771 return FWL_Error::Succeeded; | |
| 772 } | |
| 773 | |
| 774 FWL_Error IFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { | |
| 775 m_wsFont = wsFont; | |
| 776 m_fFontSize = fSize; | |
| 777 return FWL_Error::Succeeded; | |
| 778 } | |
| 779 | |
| 780 void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { | 558 void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { |
| 781 m_fScrollOffsetY = fScrollOffset; | 559 m_fScrollOffsetY = fScrollOffset; |
| 782 } | 560 } |
| 783 | 561 |
| 784 void IFWL_Edit::DrawTextBk(CFX_Graphics* pGraphics, | 562 void IFWL_Edit::DrawTextBk(CFX_Graphics* pGraphics, |
| 785 IFWL_ThemeProvider* pTheme, | 563 IFWL_ThemeProvider* pTheme, |
| 786 const CFX_Matrix* pMatrix) { | 564 const CFX_Matrix* pMatrix) { |
| 787 CFWL_ThemeBackground param; | 565 CFWL_ThemeBackground param; |
| 788 param.m_pWidget = this; | 566 param.m_pWidget = this; |
| 789 param.m_iPart = CFWL_Part::Background; | 567 param.m_iPart = CFWL_Part::Background; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 809 m_rtClient.bottom() - rtScorll.height, rtScorll.height, | 587 m_rtClient.bottom() - rtScorll.height, rtScorll.height, |
| 810 rtScorll.height); | 588 rtScorll.height); |
| 811 param.m_bStaticBackground = true; | 589 param.m_bStaticBackground = true; |
| 812 param.m_bMaximize = true; | 590 param.m_bMaximize = true; |
| 813 param.m_rtPart = rtStatic; | 591 param.m_rtPart = rtStatic; |
| 814 pTheme->DrawBackground(¶m); | 592 pTheme->DrawBackground(¶m); |
| 815 } | 593 } |
| 816 void IFWL_Edit::DrawContent(CFX_Graphics* pGraphics, | 594 void IFWL_Edit::DrawContent(CFX_Graphics* pGraphics, |
| 817 IFWL_ThemeProvider* pTheme, | 595 IFWL_ThemeProvider* pTheme, |
| 818 const CFX_Matrix* pMatrix) { | 596 const CFX_Matrix* pMatrix) { |
| 819 if (!m_pEdtEngine) | 597 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); |
| 820 return; | |
| 821 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); | |
| 822 if (!pPage) | 598 if (!pPage) |
| 823 return; | 599 return; |
| 824 pGraphics->SaveGraphState(); | 600 pGraphics->SaveGraphState(); |
| 825 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { | 601 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { |
| 826 pGraphics->SaveGraphState(); | 602 pGraphics->SaveGraphState(); |
| 827 } | 603 } |
| 828 CFX_RectF rtClip = m_rtEngine; | 604 CFX_RectF rtClip = m_rtEngine; |
| 829 FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; | 605 FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; |
| 830 FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; | 606 FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; |
| 831 CFX_Matrix mt; | 607 CFX_Matrix mt; |
| 832 mt.Set(1, 0, 0, 1, fOffSetX, fOffSetY); | 608 mt.Set(1, 0, 0, 1, fOffSetX, fOffSetY); |
| 833 if (pMatrix) { | 609 if (pMatrix) { |
| 834 pMatrix->TransformRect(rtClip); | 610 pMatrix->TransformRect(rtClip); |
| 835 mt.Concat(*pMatrix); | 611 mt.Concat(*pMatrix); |
| 836 } | 612 } |
| 837 bool bShowSel = (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoHideSel) || | 613 bool bShowSel = (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoHideSel) || |
| 838 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); | 614 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); |
| 839 if (bShowSel) { | 615 if (bShowSel) { |
| 840 IFWL_Widget* pForm = m_pWidgetMgr->GetSystemFormWidget(this); | 616 IFWL_Widget* pForm = m_pWidgetMgr->GetSystemFormWidget(this); |
| 841 if (pForm) { | 617 if (pForm) { |
| 842 bShowSel = (pForm->GetStates() & FWL_WGTSTATE_Deactivated) != | 618 bShowSel = (pForm->GetStates() & FWL_WGTSTATE_Deactivated) != |
| 843 FWL_WGTSTATE_Deactivated; | 619 FWL_WGTSTATE_Deactivated; |
| 844 } | 620 } |
| 845 } | 621 } |
| 846 int32_t nSelCount = m_pEdtEngine->CountSelRanges(); | 622 int32_t nSelCount = m_EdtEngine.CountSelRanges(); |
| 847 if (bShowSel && nSelCount > 0) { | 623 if (bShowSel && nSelCount > 0) { |
| 848 int32_t nPageCharStart = pPage->GetCharStart(); | 624 int32_t nPageCharStart = pPage->GetCharStart(); |
| 849 int32_t nPageCharCount = pPage->GetCharCount(); | 625 int32_t nPageCharCount = pPage->GetCharCount(); |
| 850 int32_t nPageCharEnd = nPageCharStart + nPageCharCount - 1; | 626 int32_t nPageCharEnd = nPageCharStart + nPageCharCount - 1; |
| 851 int32_t nCharCount; | 627 int32_t nCharCount; |
| 852 int32_t nCharStart; | 628 int32_t nCharStart; |
| 853 CFX_RectFArray rectArr; | 629 CFX_RectFArray rectArr; |
| 854 int32_t i = 0; | 630 int32_t i = 0; |
| 855 for (i = 0; i < nSelCount; i++) { | 631 for (i = 0; i < nSelCount; i++) { |
| 856 nCharCount = m_pEdtEngine->GetSelRange(i, nCharStart); | 632 nCharCount = m_EdtEngine.GetSelRange(i, nCharStart); |
| 857 int32_t nCharEnd = nCharStart + nCharCount - 1; | 633 int32_t nCharEnd = nCharStart + nCharCount - 1; |
| 858 if (nCharEnd < nPageCharStart || nCharStart > nPageCharEnd) { | 634 if (nCharEnd < nPageCharStart || nCharStart > nPageCharEnd) { |
| 859 continue; | 635 continue; |
| 860 } | 636 } |
| 861 int32_t nBgn = std::max(nCharStart, nPageCharStart); | 637 int32_t nBgn = std::max(nCharStart, nPageCharStart); |
| 862 int32_t nEnd = std::min(nCharEnd, nPageCharEnd); | 638 int32_t nEnd = std::min(nCharEnd, nPageCharEnd); |
| 863 pPage->CalcRangeRectArray(nBgn - nPageCharStart, nEnd - nBgn + 1, | 639 pPage->CalcRangeRectArray(nBgn - nPageCharStart, nEnd - nBgn + 1, |
| 864 rectArr); | 640 rectArr); |
| 865 } | 641 } |
| 866 int32_t nCount = rectArr.GetSize(); | 642 int32_t nCount = rectArr.GetSize(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 param.m_pPath = &path; | 686 param.m_pPath = &path; |
| 911 pTheme->DrawBackground(¶m); | 687 pTheme->DrawBackground(¶m); |
| 912 } | 688 } |
| 913 pGraphics->RestoreGraphState(); | 689 pGraphics->RestoreGraphState(); |
| 914 } | 690 } |
| 915 | 691 |
| 916 void IFWL_Edit::UpdateEditEngine() { | 692 void IFWL_Edit::UpdateEditEngine() { |
| 917 UpdateEditParams(); | 693 UpdateEditParams(); |
| 918 UpdateEditLayout(); | 694 UpdateEditLayout(); |
| 919 if (m_nLimit > -1) { | 695 if (m_nLimit > -1) { |
| 920 m_pEdtEngine->SetLimit(m_nLimit); | 696 m_EdtEngine.SetLimit(m_nLimit); |
| 921 } | 697 } |
| 922 } | 698 } |
| 923 void IFWL_Edit::UpdateEditParams() { | 699 void IFWL_Edit::UpdateEditParams() { |
| 924 FDE_TXTEDTPARAMS params; | 700 FDE_TXTEDTPARAMS params; |
| 925 params.nHorzScale = 100; | 701 params.nHorzScale = 100; |
| 926 params.fPlateWidth = m_rtEngine.width; | 702 params.fPlateWidth = m_rtEngine.width; |
| 927 params.fPlateHeight = m_rtEngine.height; | 703 params.fPlateHeight = m_rtEngine.height; |
| 928 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_RTLLayout) { | 704 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_RTLLayout) { |
| 929 params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_RTL; | 705 params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_RTL; |
| 930 } | 706 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 params.fFontSize = m_fFontSize; | 802 params.fFontSize = m_fFontSize; |
| 1027 params.nLineCount = (int32_t)(params.fPlateHeight / params.fLineSpace); | 803 params.nLineCount = (int32_t)(params.fPlateHeight / params.fLineSpace); |
| 1028 if (params.nLineCount <= 0) { | 804 if (params.nLineCount <= 0) { |
| 1029 params.nLineCount = 1; | 805 params.nLineCount = 1; |
| 1030 } | 806 } |
| 1031 params.fTabWidth = params.fFontSize * 1; | 807 params.fTabWidth = params.fFontSize * 1; |
| 1032 params.bTabEquidistant = true; | 808 params.bTabEquidistant = true; |
| 1033 params.wLineBreakChar = L'\n'; | 809 params.wLineBreakChar = L'\n'; |
| 1034 params.nCharRotation = 0; | 810 params.nCharRotation = 0; |
| 1035 params.pEventSink = this; | 811 params.pEventSink = this; |
| 1036 m_pEdtEngine->SetEditParams(params); | 812 m_EdtEngine.SetEditParams(params); |
| 1037 } | 813 } |
| 1038 | 814 |
| 1039 void IFWL_Edit::UpdateEditLayout() { | 815 void IFWL_Edit::UpdateEditLayout() { |
| 1040 if (m_pEdtEngine->GetTextLength() <= 0) | 816 if (m_EdtEngine.GetTextLength() <= 0) |
| 1041 m_pEdtEngine->SetTextByStream(nullptr); | 817 m_EdtEngine.SetTextByStream(nullptr); |
| 1042 | 818 |
| 1043 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); | 819 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); |
| 1044 if (pPage) | 820 if (pPage) |
| 1045 pPage->UnloadPage(nullptr); | 821 pPage->UnloadPage(nullptr); |
| 1046 | 822 |
| 1047 m_pEdtEngine->StartLayout(); | 823 m_EdtEngine.StartLayout(); |
| 1048 m_pEdtEngine->DoLayout(nullptr); | 824 m_EdtEngine.DoLayout(nullptr); |
| 1049 m_pEdtEngine->EndLayout(); | 825 m_EdtEngine.EndLayout(); |
| 1050 pPage = m_pEdtEngine->GetPage(0); | 826 pPage = m_EdtEngine.GetPage(0); |
| 1051 if (pPage) | 827 if (pPage) |
| 1052 pPage->LoadPage(nullptr, nullptr); | 828 pPage->LoadPage(nullptr, nullptr); |
| 1053 } | 829 } |
| 1054 | 830 |
| 1055 bool IFWL_Edit::UpdateOffset() { | 831 bool IFWL_Edit::UpdateOffset() { |
| 1056 CFX_RectF rtCaret; | 832 CFX_RectF rtCaret; |
| 1057 m_pEdtEngine->GetCaretRect(rtCaret); | 833 m_EdtEngine.GetCaretRect(rtCaret); |
| 1058 FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; | 834 FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; |
| 1059 FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; | 835 FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; |
| 1060 rtCaret.Offset(fOffSetX, fOffSetY); | 836 rtCaret.Offset(fOffSetX, fOffSetY); |
| 1061 const CFX_RectF& rtEidt = m_rtEngine; | 837 const CFX_RectF& rtEidt = m_rtEngine; |
| 1062 if (rtEidt.Contains(rtCaret)) { | 838 if (rtEidt.Contains(rtCaret)) { |
| 1063 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); | 839 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); |
| 1064 if (!pPage) | 840 if (!pPage) |
| 1065 return false; | 841 return false; |
| 1066 | 842 |
| 1067 CFX_RectF rtFDE = pPage->GetContentsBox(); | 843 CFX_RectF rtFDE = pPage->GetContentsBox(); |
| 1068 rtFDE.Offset(fOffSetX, fOffSetY); | 844 rtFDE.Offset(fOffSetX, fOffSetY); |
| 1069 if (rtFDE.right() < rtEidt.right() && m_fScrollOffsetX > 0) { | 845 if (rtFDE.right() < rtEidt.right() && m_fScrollOffsetX > 0) { |
| 1070 m_fScrollOffsetX += rtFDE.right() - rtEidt.right(); | 846 m_fScrollOffsetX += rtFDE.right() - rtEidt.right(); |
| 1071 m_fScrollOffsetX = std::max(m_fScrollOffsetX, 0.0f); | 847 m_fScrollOffsetX = std::max(m_fScrollOffsetX, 0.0f); |
| 1072 } | 848 } |
| 1073 if (rtFDE.bottom() < rtEidt.bottom() && m_fScrollOffsetY > 0) { | 849 if (rtFDE.bottom() < rtEidt.bottom() && m_fScrollOffsetY > 0) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1098 | 874 |
| 1099 bool IFWL_Edit::UpdateOffset(IFWL_ScrollBar* pScrollBar, FX_FLOAT fPosChanged) { | 875 bool IFWL_Edit::UpdateOffset(IFWL_ScrollBar* pScrollBar, FX_FLOAT fPosChanged) { |
| 1100 if (pScrollBar == m_pHorzScrollBar.get()) | 876 if (pScrollBar == m_pHorzScrollBar.get()) |
| 1101 m_fScrollOffsetX += fPosChanged; | 877 m_fScrollOffsetX += fPosChanged; |
| 1102 else | 878 else |
| 1103 m_fScrollOffsetY += fPosChanged; | 879 m_fScrollOffsetY += fPosChanged; |
| 1104 return true; | 880 return true; |
| 1105 } | 881 } |
| 1106 | 882 |
| 1107 void IFWL_Edit::UpdateVAlignment() { | 883 void IFWL_Edit::UpdateVAlignment() { |
| 1108 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); | 884 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); |
| 1109 if (!pPage) | 885 if (!pPage) |
| 1110 return; | 886 return; |
| 1111 const CFX_RectF& rtFDE = pPage->GetContentsBox(); | 887 const CFX_RectF& rtFDE = pPage->GetContentsBox(); |
| 1112 FX_FLOAT fOffsetY = 0.0f; | 888 FX_FLOAT fOffsetY = 0.0f; |
| 1113 FX_FLOAT fSpaceAbove = 0.0f; | 889 FX_FLOAT fSpaceAbove = 0.0f; |
| 1114 FX_FLOAT fSpaceBelow = 0.0f; | 890 FX_FLOAT fSpaceBelow = 0.0f; |
| 1115 CFX_SizeF* pSpace = static_cast<CFX_SizeF*>( | 891 CFX_SizeF* pSpace = static_cast<CFX_SizeF*>( |
| 1116 GetThemeCapacity(CFWL_WidgetCapacity::SpaceAboveBelow)); | 892 GetThemeCapacity(CFWL_WidgetCapacity::SpaceAboveBelow)); |
| 1117 if (pSpace) { | 893 if (pSpace) { |
| 1118 fSpaceAbove = pSpace->x; | 894 fSpaceAbove = pSpace->x; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1137 } else { | 913 } else { |
| 1138 fOffsetY += fSpaceAbove; | 914 fOffsetY += fSpaceAbove; |
| 1139 } | 915 } |
| 1140 m_fVAlignOffset = fOffsetY; | 916 m_fVAlignOffset = fOffsetY; |
| 1141 if (m_fVAlignOffset < 0) { | 917 if (m_fVAlignOffset < 0) { |
| 1142 m_fVAlignOffset = 0; | 918 m_fVAlignOffset = 0; |
| 1143 } | 919 } |
| 1144 } | 920 } |
| 1145 void IFWL_Edit::UpdateCaret() { | 921 void IFWL_Edit::UpdateCaret() { |
| 1146 CFX_RectF rtFDE; | 922 CFX_RectF rtFDE; |
| 1147 m_pEdtEngine->GetCaretRect(rtFDE); | 923 m_EdtEngine.GetCaretRect(rtFDE); |
| 1148 rtFDE.Offset(m_rtEngine.left - m_fScrollOffsetX, | 924 rtFDE.Offset(m_rtEngine.left - m_fScrollOffsetX, |
| 1149 m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset); | 925 m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset); |
| 1150 CFX_RectF rtCaret; | 926 CFX_RectF rtCaret; |
| 1151 rtCaret.Set(rtFDE.left, rtFDE.top, rtFDE.width, rtFDE.height); | 927 rtCaret.Set(rtFDE.left, rtFDE.top, rtFDE.width, rtFDE.height); |
| 1152 CFX_RectF temp = rtCaret; | 928 CFX_RectF temp = rtCaret; |
| 1153 CFX_RectF rtClient; | 929 CFX_RectF rtClient; |
| 1154 GetClientRect(rtClient); | 930 GetClientRect(rtClient); |
| 1155 rtCaret.Intersect(rtClient); | 931 rtCaret.Intersect(rtClient); |
| 1156 if (rtCaret.left > rtClient.right()) { | 932 if (rtCaret.left > rtClient.right()) { |
| 1157 FX_FLOAT right = rtCaret.right(); | 933 FX_FLOAT right = rtCaret.right(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1182 IFWL_ScrollBar* IFWL_Edit::UpdateScroll() { | 958 IFWL_ScrollBar* IFWL_Edit::UpdateScroll() { |
| 1183 bool bShowHorz = | 959 bool bShowHorz = |
| 1184 m_pHorzScrollBar && | 960 m_pHorzScrollBar && |
| 1185 ((m_pHorzScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0); | 961 ((m_pHorzScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0); |
| 1186 bool bShowVert = | 962 bool bShowVert = |
| 1187 m_pVertScrollBar && | 963 m_pVertScrollBar && |
| 1188 ((m_pVertScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0); | 964 ((m_pVertScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0); |
| 1189 if (!bShowHorz && !bShowVert) { | 965 if (!bShowHorz && !bShowVert) { |
| 1190 return nullptr; | 966 return nullptr; |
| 1191 } | 967 } |
| 1192 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); | 968 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); |
| 1193 if (!pPage) | 969 if (!pPage) |
| 1194 return nullptr; | 970 return nullptr; |
| 1195 const CFX_RectF& rtFDE = pPage->GetContentsBox(); | 971 const CFX_RectF& rtFDE = pPage->GetContentsBox(); |
| 1196 IFWL_ScrollBar* pRepaint = nullptr; | 972 IFWL_ScrollBar* pRepaint = nullptr; |
| 1197 if (bShowHorz) { | 973 if (bShowHorz) { |
| 1198 CFX_RectF rtScroll; | 974 CFX_RectF rtScroll; |
| 1199 m_pHorzScrollBar->GetWidgetRect(rtScroll); | 975 m_pHorzScrollBar->GetWidgetRect(rtScroll); |
| 1200 if (rtScroll.width < rtFDE.width) { | 976 if (rtScroll.width < rtFDE.width) { |
| 1201 m_pHorzScrollBar->LockUpdate(); | 977 m_pHorzScrollBar->LockUpdate(); |
| 1202 FX_FLOAT fRange = rtFDE.width - rtScroll.width; | 978 FX_FLOAT fRange = rtFDE.width - rtScroll.width; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1223 m_pHorzScrollBar->UnlockUpdate(); | 999 m_pHorzScrollBar->UnlockUpdate(); |
| 1224 m_pHorzScrollBar->Update(); | 1000 m_pHorzScrollBar->Update(); |
| 1225 pRepaint = m_pHorzScrollBar.get(); | 1001 pRepaint = m_pHorzScrollBar.get(); |
| 1226 } | 1002 } |
| 1227 } | 1003 } |
| 1228 if (bShowVert) { | 1004 if (bShowVert) { |
| 1229 CFX_RectF rtScroll; | 1005 CFX_RectF rtScroll; |
| 1230 m_pVertScrollBar->GetWidgetRect(rtScroll); | 1006 m_pVertScrollBar->GetWidgetRect(rtScroll); |
| 1231 if (rtScroll.height < rtFDE.height) { | 1007 if (rtScroll.height < rtFDE.height) { |
| 1232 m_pVertScrollBar->LockUpdate(); | 1008 m_pVertScrollBar->LockUpdate(); |
| 1233 FX_FLOAT fStep = m_pEdtEngine->GetEditParams()->fLineSpace; | 1009 FX_FLOAT fStep = m_EdtEngine.GetEditParams()->fLineSpace; |
| 1234 FX_FLOAT fRange = rtFDE.height - m_rtEngine.height; | 1010 FX_FLOAT fRange = rtFDE.height - m_rtEngine.height; |
| 1235 if (fRange < fStep) { | 1011 if (fRange < fStep) { |
| 1236 fRange = fStep; | 1012 fRange = fStep; |
| 1237 } | 1013 } |
| 1238 m_pVertScrollBar->SetRange(0.0f, fRange); | 1014 m_pVertScrollBar->SetRange(0.0f, fRange); |
| 1239 FX_FLOAT fPos = m_fScrollOffsetY; | 1015 FX_FLOAT fPos = m_fScrollOffsetY; |
| 1240 if (fPos < 0.0f) { | 1016 if (fPos < 0.0f) { |
| 1241 fPos = 0.0f; | 1017 fPos = 0.0f; |
| 1242 } | 1018 } |
| 1243 if (fPos > fRange) { | 1019 if (fPos > fRange) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1270 : true; | 1046 : true; |
| 1271 if (bVert) { | 1047 if (bVert) { |
| 1272 return bShow && (m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll) && | 1048 return bShow && (m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll) && |
| 1273 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) && | 1049 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) && |
| 1274 IsContentHeightOverflow(); | 1050 IsContentHeightOverflow(); |
| 1275 } | 1051 } |
| 1276 return bShow && (m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) && | 1052 return bShow && (m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) && |
| 1277 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); | 1053 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); |
| 1278 } | 1054 } |
| 1279 bool IFWL_Edit::IsContentHeightOverflow() { | 1055 bool IFWL_Edit::IsContentHeightOverflow() { |
| 1280 if (!m_pEdtEngine) | 1056 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); |
| 1281 return false; | |
| 1282 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); | |
| 1283 if (!pPage) | 1057 if (!pPage) |
| 1284 return false; | 1058 return false; |
| 1285 return pPage->GetContentsBox().height > m_rtEngine.height + 1.0f; | 1059 return pPage->GetContentsBox().height > m_rtEngine.height + 1.0f; |
| 1286 } | 1060 } |
| 1287 int32_t IFWL_Edit::AddDoRecord(IFDE_TxtEdtDoRecord* pRecord) { | 1061 int32_t IFWL_Edit::AddDoRecord(IFDE_TxtEdtDoRecord* pRecord) { |
| 1288 int32_t nCount = pdfium::CollectionSize<int32_t>(m_DoRecords); | 1062 int32_t nCount = pdfium::CollectionSize<int32_t>(m_DoRecords); |
| 1289 if (m_iCurRecord == nCount - 1) { | 1063 if (m_iCurRecord == nCount - 1) { |
| 1290 if (nCount == m_iMaxRecord) { | 1064 if (nCount == m_iMaxRecord) { |
| 1291 m_DoRecords.pop_front(); | 1065 m_DoRecords.pop_front(); |
| 1292 m_iCurRecord--; | 1066 m_iCurRecord--; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1448 prop->m_pParent = this; | 1222 prop->m_pParent = this; |
| 1449 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider; | 1223 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider; |
| 1450 | 1224 |
| 1451 IFWL_ScrollBar* sb = new IFWL_ScrollBar(m_pOwnerApp, std::move(prop), this); | 1225 IFWL_ScrollBar* sb = new IFWL_ScrollBar(m_pOwnerApp, std::move(prop), this); |
| 1452 if (bVert) | 1226 if (bVert) |
| 1453 m_pVertScrollBar.reset(sb); | 1227 m_pVertScrollBar.reset(sb); |
| 1454 else | 1228 else |
| 1455 m_pHorzScrollBar.reset(sb); | 1229 m_pHorzScrollBar.reset(sb); |
| 1456 } | 1230 } |
| 1457 | 1231 |
| 1458 void IFWL_Edit::InitEngine() { | |
| 1459 if (!m_pEdtEngine) | |
| 1460 m_pEdtEngine.reset(new CFDE_TxtEdtEngine); | |
| 1461 } | |
| 1462 | |
| 1463 bool FWL_ShowCaret(IFWL_Widget* pWidget, | 1232 bool FWL_ShowCaret(IFWL_Widget* pWidget, |
| 1464 bool bVisible, | 1233 bool bVisible, |
| 1465 const CFX_RectF* pRtAnchor) { | 1234 const CFX_RectF* pRtAnchor) { |
| 1466 CXFA_FFWidget* pXFAWidget = | 1235 CXFA_FFWidget* pXFAWidget = |
| 1467 static_cast<CXFA_FFWidget*>(pWidget->GetLayoutItem()); | 1236 static_cast<CXFA_FFWidget*>(pWidget->GetLayoutItem()); |
| 1468 if (!pXFAWidget) | 1237 if (!pXFAWidget) |
| 1469 return false; | 1238 return false; |
| 1470 | 1239 |
| 1471 IXFA_DocEnvironment* pDocEnvironment = | 1240 IXFA_DocEnvironment* pDocEnvironment = |
| 1472 pXFAWidget->GetDoc()->GetDocEnvironment(); | 1241 pXFAWidget->GetDoc()->GetDocEnvironment(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1503 if (bVisible) { | 1272 if (bVisible) { |
| 1504 CFX_RectF rtOuter; | 1273 CFX_RectF rtOuter; |
| 1505 pOuter->GetWidgetRect(rtOuter); | 1274 pOuter->GetWidgetRect(rtOuter); |
| 1506 pRect->Offset(rtOuter.left, rtOuter.top); | 1275 pRect->Offset(rtOuter.left, rtOuter.top); |
| 1507 } | 1276 } |
| 1508 } | 1277 } |
| 1509 FWL_ShowCaret(pOuter, bVisible, pRect); | 1278 FWL_ShowCaret(pOuter, bVisible, pRect); |
| 1510 } | 1279 } |
| 1511 } | 1280 } |
| 1512 bool IFWL_Edit::ValidateNumberChar(FX_WCHAR cNum) { | 1281 bool IFWL_Edit::ValidateNumberChar(FX_WCHAR cNum) { |
| 1513 if (!m_pEdtEngine) { | |
| 1514 return false; | |
| 1515 } | |
| 1516 if (!m_bSetRange) { | 1282 if (!m_bSetRange) { |
| 1517 return true; | 1283 return true; |
| 1518 } | 1284 } |
| 1519 CFX_WideString wsOld, wsText; | 1285 CFX_WideString wsOld, wsText; |
| 1520 m_pEdtEngine->GetText(wsText, 0); | 1286 m_EdtEngine.GetText(wsText, 0); |
| 1521 if (wsText.IsEmpty()) { | 1287 if (wsText.IsEmpty()) { |
| 1522 if (cNum == L'0') { | 1288 if (cNum == L'0') { |
| 1523 return false; | 1289 return false; |
| 1524 } | 1290 } |
| 1525 return true; | 1291 return true; |
| 1526 } | 1292 } |
| 1527 int32_t caretPos = m_pEdtEngine->GetCaretPos(); | 1293 int32_t caretPos = m_EdtEngine.GetCaretPos(); |
| 1528 int32_t iSel = CountSelRanges(); | 1294 int32_t iSel = CountSelRanges(); |
| 1529 if (iSel == 0) { | 1295 if (iSel == 0) { |
| 1530 if (cNum == L'0' && caretPos == 0) { | 1296 if (cNum == L'0' && caretPos == 0) { |
| 1531 return false; | 1297 return false; |
| 1532 } | 1298 } |
| 1533 int32_t nLen = wsText.GetLength(); | 1299 int32_t nLen = wsText.GetLength(); |
| 1534 CFX_WideString l = wsText.Mid(0, caretPos); | 1300 CFX_WideString l = wsText.Mid(0, caretPos); |
| 1535 CFX_WideString r = wsText.Mid(caretPos, nLen - caretPos); | 1301 CFX_WideString r = wsText.Mid(caretPos, nLen - caretPos); |
| 1536 CFX_WideString wsNew = l + cNum + r; | 1302 CFX_WideString wsNew = l + cNum + r; |
| 1537 if (wsNew.GetInteger() <= m_iMax) { | 1303 if (wsNew.GetInteger() <= m_iMax) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1564 } | 1330 } |
| 1565 | 1331 |
| 1566 void IFWL_Edit::ProcessInsertError(int32_t iError) { | 1332 void IFWL_Edit::ProcessInsertError(int32_t iError) { |
| 1567 switch (iError) { | 1333 switch (iError) { |
| 1568 case -2: { | 1334 case -2: { |
| 1569 CFWL_EvtEdtTextFull textFullEvent; | 1335 CFWL_EvtEdtTextFull textFullEvent; |
| 1570 textFullEvent.m_pSrcTarget = this; | 1336 textFullEvent.m_pSrcTarget = this; |
| 1571 DispatchEvent(&textFullEvent); | 1337 DispatchEvent(&textFullEvent); |
| 1572 break; | 1338 break; |
| 1573 } | 1339 } |
| 1574 default: {} | 1340 default: |
| 1341 break; |
| 1575 } | 1342 } |
| 1576 } | 1343 } |
| 1577 | 1344 |
| 1578 void IFWL_Edit::OnProcessMessage(CFWL_Message* pMessage) { | 1345 void IFWL_Edit::OnProcessMessage(CFWL_Message* pMessage) { |
| 1579 if (!pMessage) | 1346 if (!pMessage) |
| 1580 return; | 1347 return; |
| 1581 | 1348 |
| 1582 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); | 1349 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); |
| 1583 switch (dwMsgCode) { | 1350 switch (dwMsgCode) { |
| 1584 case CFWL_MessageType::Activate: | 1351 case CFWL_MessageType::Activate: |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1654 } | 1421 } |
| 1655 | 1422 |
| 1656 void IFWL_Edit::DoDeactivate(CFWL_MsgDeactivate* pMsg) { | 1423 void IFWL_Edit::DoDeactivate(CFWL_MsgDeactivate* pMsg) { |
| 1657 m_pProperties->m_dwStates &= FWL_WGTSTATE_Deactivated; | 1424 m_pProperties->m_dwStates &= FWL_WGTSTATE_Deactivated; |
| 1658 Repaint(&m_rtClient); | 1425 Repaint(&m_rtClient); |
| 1659 } | 1426 } |
| 1660 | 1427 |
| 1661 void IFWL_Edit::DoButtonDown(CFWL_MsgMouse* pMsg) { | 1428 void IFWL_Edit::DoButtonDown(CFWL_MsgMouse* pMsg) { |
| 1662 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) | 1429 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) |
| 1663 SetFocus(true); | 1430 SetFocus(true); |
| 1664 if (!m_pEdtEngine) | |
| 1665 UpdateEditEngine(); | |
| 1666 | 1431 |
| 1667 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); | 1432 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); |
| 1668 if (!pPage) | 1433 if (!pPage) |
| 1669 return; | 1434 return; |
| 1670 CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); | 1435 CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); |
| 1671 DeviceToEngine(pt); | 1436 DeviceToEngine(pt); |
| 1672 bool bBefore = true; | 1437 bool bBefore = true; |
| 1673 int32_t nIndex = pPage->GetCharIndex(pt, bBefore); | 1438 int32_t nIndex = pPage->GetCharIndex(pt, bBefore); |
| 1674 if (nIndex < 0) | 1439 if (nIndex < 0) |
| 1675 nIndex = 0; | 1440 nIndex = 0; |
| 1676 | 1441 |
| 1677 m_pEdtEngine->SetCaretPos(nIndex, bBefore); | 1442 m_EdtEngine.SetCaretPos(nIndex, bBefore); |
| 1678 } | 1443 } |
| 1679 | 1444 |
| 1680 void IFWL_Edit::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { | 1445 void IFWL_Edit::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { |
| 1681 uint32_t dwStyleEx = GetStylesEx(); | 1446 uint32_t dwStyleEx = GetStylesEx(); |
| 1682 bool bRepaint = !!(dwStyleEx & FWL_STYLEEXT_EDT_InnerCaret); | 1447 bool bRepaint = !!(dwStyleEx & FWL_STYLEEXT_EDT_InnerCaret); |
| 1683 if (bSet) { | 1448 if (bSet) { |
| 1684 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; | 1449 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; |
| 1685 if (!m_pEdtEngine) | |
| 1686 UpdateEditEngine(); | |
| 1687 | 1450 |
| 1688 UpdateVAlignment(); | 1451 UpdateVAlignment(); |
| 1689 UpdateOffset(); | 1452 UpdateOffset(); |
| 1690 UpdateCaret(); | 1453 UpdateCaret(); |
| 1691 } else if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { | 1454 } else if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { |
| 1692 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; | 1455 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; |
| 1693 ShowCaret(false); | 1456 ShowCaret(false); |
| 1694 if (m_pEdtEngine && (dwStyleEx & FWL_STYLEEXT_EDT_NoHideSel) == 0) { | 1457 if ((dwStyleEx & FWL_STYLEEXT_EDT_NoHideSel) == 0) { |
| 1695 int32_t nSel = CountSelRanges(); | 1458 int32_t nSel = CountSelRanges(); |
| 1696 if (nSel > 0) { | 1459 if (nSel > 0) { |
| 1697 ClearSelections(); | 1460 ClearSelections(); |
| 1698 bRepaint = true; | 1461 bRepaint = true; |
| 1699 } | 1462 } |
| 1700 SetCaretPos(0); | 1463 m_EdtEngine.SetCaretPos(0, true); |
| 1701 UpdateOffset(); | 1464 UpdateOffset(); |
| 1702 } | 1465 } |
| 1703 ClearRecord(); | 1466 ClearRecord(); |
| 1704 } | 1467 } |
| 1705 LayoutScrollBar(); | 1468 LayoutScrollBar(); |
| 1706 if (bRepaint) { | 1469 if (bRepaint) { |
| 1707 CFX_RectF rtInvalidate; | 1470 CFX_RectF rtInvalidate; |
| 1708 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, | 1471 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, |
| 1709 m_pProperties->m_rtWidget.height); | 1472 m_pProperties->m_rtWidget.height); |
| 1710 Repaint(&rtInvalidate); | 1473 Repaint(&rtInvalidate); |
| 1711 } | 1474 } |
| 1712 } | 1475 } |
| 1713 | 1476 |
| 1714 void IFWL_Edit::OnLButtonDown(CFWL_MsgMouse* pMsg) { | 1477 void IFWL_Edit::OnLButtonDown(CFWL_MsgMouse* pMsg) { |
| 1715 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) | 1478 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) |
| 1716 return; | 1479 return; |
| 1717 | 1480 |
| 1718 m_bLButtonDown = true; | 1481 m_bLButtonDown = true; |
| 1719 SetGrab(true); | 1482 SetGrab(true); |
| 1720 DoButtonDown(pMsg); | 1483 DoButtonDown(pMsg); |
| 1721 int32_t nIndex = m_pEdtEngine->GetCaretPos(); | 1484 int32_t nIndex = m_EdtEngine.GetCaretPos(); |
| 1722 bool bRepaint = false; | 1485 bool bRepaint = false; |
| 1723 int32_t iCount = m_pEdtEngine->CountSelRanges(); | 1486 int32_t iCount = m_EdtEngine.CountSelRanges(); |
| 1724 if (iCount > 0) { | 1487 if (iCount > 0) { |
| 1725 m_pEdtEngine->ClearSelection(); | 1488 m_EdtEngine.ClearSelection(); |
| 1726 bRepaint = true; | 1489 bRepaint = true; |
| 1727 } | 1490 } |
| 1728 | 1491 |
| 1729 bool bShift = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Shift); | 1492 bool bShift = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Shift); |
| 1730 if (bShift && m_nSelStart != nIndex) { | 1493 if (bShift && m_nSelStart != nIndex) { |
| 1731 int32_t iStart = std::min(m_nSelStart, nIndex); | 1494 int32_t iStart = std::min(m_nSelStart, nIndex); |
| 1732 int32_t iEnd = std::max(m_nSelStart, nIndex); | 1495 int32_t iEnd = std::max(m_nSelStart, nIndex); |
| 1733 m_pEdtEngine->AddSelRange(iStart, iEnd - iStart); | 1496 m_EdtEngine.AddSelRange(iStart, iEnd - iStart); |
| 1734 bRepaint = true; | 1497 bRepaint = true; |
| 1735 } else { | 1498 } else { |
| 1736 m_nSelStart = nIndex; | 1499 m_nSelStart = nIndex; |
| 1737 } | 1500 } |
| 1738 if (bRepaint) | 1501 if (bRepaint) |
| 1739 Repaint(&m_rtEngine); | 1502 Repaint(&m_rtEngine); |
| 1740 } | 1503 } |
| 1741 | 1504 |
| 1742 void IFWL_Edit::OnLButtonUp(CFWL_MsgMouse* pMsg) { | 1505 void IFWL_Edit::OnLButtonUp(CFWL_MsgMouse* pMsg) { |
| 1743 m_bLButtonDown = false; | 1506 m_bLButtonDown = false; |
| 1744 SetGrab(false); | 1507 SetGrab(false); |
| 1745 } | 1508 } |
| 1746 | 1509 |
| 1747 void IFWL_Edit::OnButtonDblClk(CFWL_MsgMouse* pMsg) { | 1510 void IFWL_Edit::OnButtonDblClk(CFWL_MsgMouse* pMsg) { |
| 1748 if (!m_pEdtEngine) | 1511 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); |
| 1749 return; | |
| 1750 | |
| 1751 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); | |
| 1752 if (!pPage) | 1512 if (!pPage) |
| 1753 return; | 1513 return; |
| 1754 | 1514 |
| 1755 CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); | 1515 CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); |
| 1756 DeviceToEngine(pt); | 1516 DeviceToEngine(pt); |
| 1757 int32_t nCount = 0; | 1517 int32_t nCount = 0; |
| 1758 int32_t nIndex = pPage->SelectWord(pt, nCount); | 1518 int32_t nIndex = pPage->SelectWord(pt, nCount); |
| 1759 if (nIndex < 0) | 1519 if (nIndex < 0) |
| 1760 return; | 1520 return; |
| 1761 | 1521 |
| 1762 m_pEdtEngine->AddSelRange(nIndex, nCount); | 1522 m_EdtEngine.AddSelRange(nIndex, nCount); |
| 1763 m_pEdtEngine->SetCaretPos(nIndex + nCount - 1, false); | 1523 m_EdtEngine.SetCaretPos(nIndex + nCount - 1, false); |
| 1764 Repaint(&m_rtEngine); | 1524 Repaint(&m_rtEngine); |
| 1765 } | 1525 } |
| 1766 | 1526 |
| 1767 void IFWL_Edit::OnMouseMove(CFWL_MsgMouse* pMsg) { | 1527 void IFWL_Edit::OnMouseMove(CFWL_MsgMouse* pMsg) { |
| 1768 if (!m_pEdtEngine) | |
| 1769 return; | |
| 1770 if (m_nSelStart == -1 || !m_bLButtonDown) | 1528 if (m_nSelStart == -1 || !m_bLButtonDown) |
| 1771 return; | 1529 return; |
| 1772 | 1530 |
| 1773 IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); | 1531 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); |
| 1774 if (!pPage) | 1532 if (!pPage) |
| 1775 return; | 1533 return; |
| 1776 | 1534 |
| 1777 CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); | 1535 CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); |
| 1778 DeviceToEngine(pt); | 1536 DeviceToEngine(pt); |
| 1779 bool bBefore = true; | 1537 bool bBefore = true; |
| 1780 int32_t nIndex = pPage->GetCharIndex(pt, bBefore); | 1538 int32_t nIndex = pPage->GetCharIndex(pt, bBefore); |
| 1781 m_pEdtEngine->SetCaretPos(nIndex, bBefore); | 1539 m_EdtEngine.SetCaretPos(nIndex, bBefore); |
| 1782 nIndex = m_pEdtEngine->GetCaretPos(); | 1540 nIndex = m_EdtEngine.GetCaretPos(); |
| 1783 m_pEdtEngine->ClearSelection(); | 1541 m_EdtEngine.ClearSelection(); |
| 1784 if (nIndex != m_nSelStart) { | 1542 if (nIndex != m_nSelStart) { |
| 1785 int32_t nLen = m_pEdtEngine->GetTextLength(); | 1543 int32_t nLen = m_EdtEngine.GetTextLength(); |
| 1786 if (m_nSelStart >= nLen) | 1544 if (m_nSelStart >= nLen) |
| 1787 m_nSelStart = nLen; | 1545 m_nSelStart = nLen; |
| 1788 | 1546 |
| 1789 m_pEdtEngine->AddSelRange(std::min(m_nSelStart, nIndex), | 1547 m_EdtEngine.AddSelRange(std::min(m_nSelStart, nIndex), |
| 1790 FXSYS_abs(nIndex - m_nSelStart)); | 1548 FXSYS_abs(nIndex - m_nSelStart)); |
| 1791 } | 1549 } |
| 1792 } | 1550 } |
| 1793 | 1551 |
| 1794 void IFWL_Edit::OnKeyDown(CFWL_MsgKey* pMsg) { | 1552 void IFWL_Edit::OnKeyDown(CFWL_MsgKey* pMsg) { |
| 1795 if (!m_pEdtEngine) | |
| 1796 return; | |
| 1797 | |
| 1798 FDE_TXTEDTMOVECARET MoveCaret = MC_MoveNone; | 1553 FDE_TXTEDTMOVECARET MoveCaret = MC_MoveNone; |
| 1799 bool bShift = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Shift); | 1554 bool bShift = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Shift); |
| 1800 bool bCtrl = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl); | 1555 bool bCtrl = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl); |
| 1801 uint32_t dwKeyCode = pMsg->m_dwKeyCode; | 1556 uint32_t dwKeyCode = pMsg->m_dwKeyCode; |
| 1802 switch (dwKeyCode) { | 1557 switch (dwKeyCode) { |
| 1803 case FWL_VKEY_Left: { | 1558 case FWL_VKEY_Left: { |
| 1804 MoveCaret = MC_Left; | 1559 MoveCaret = MC_Left; |
| 1805 break; | 1560 break; |
| 1806 } | 1561 } |
| 1807 case FWL_VKEY_Right: { | 1562 case FWL_VKEY_Right: { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1824 MoveCaret = bCtrl ? MC_End : MC_LineEnd; | 1579 MoveCaret = bCtrl ? MC_End : MC_LineEnd; |
| 1825 break; | 1580 break; |
| 1826 } | 1581 } |
| 1827 case FWL_VKEY_Insert: | 1582 case FWL_VKEY_Insert: |
| 1828 break; | 1583 break; |
| 1829 case FWL_VKEY_Delete: { | 1584 case FWL_VKEY_Delete: { |
| 1830 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || | 1585 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || |
| 1831 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { | 1586 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { |
| 1832 break; | 1587 break; |
| 1833 } | 1588 } |
| 1834 int32_t nCaret = m_pEdtEngine->GetCaretPos(); | 1589 int32_t nCaret = m_EdtEngine.GetCaretPos(); |
| 1835 #if (_FX_OS_ == _FX_MACOSX_) | 1590 #if (_FX_OS_ == _FX_MACOSX_) |
| 1836 m_pEdtEngine->Delete(nCaret, true); | 1591 m_EdtEngine.Delete(nCaret, true); |
| 1837 #else | 1592 #else |
| 1838 m_pEdtEngine->Delete(nCaret); | 1593 m_EdtEngine.Delete(nCaret); |
| 1839 #endif | 1594 #endif |
| 1840 break; | 1595 break; |
| 1841 } | 1596 } |
| 1842 case FWL_VKEY_F2: | 1597 case FWL_VKEY_F2: |
| 1843 break; | 1598 break; |
| 1844 case FWL_VKEY_Tab: { | 1599 case FWL_VKEY_Tab: { |
| 1845 DispatchKeyEvent(pMsg); | 1600 DispatchKeyEvent(pMsg); |
| 1846 break; | 1601 break; |
| 1847 } | 1602 } |
| 1848 default: { | 1603 default: |
| 1849 #if (_FX_OS_ == _FX_MACOSX_) | 1604 break; |
| 1850 if (pMsg->m_dwFlags & FWL_KEYFLAG_Command) { | |
| 1851 #else | |
| 1852 if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) { | |
| 1853 #endif | |
| 1854 if (dwKeyCode == 0x43 || dwKeyCode == 0x63) { | |
| 1855 DoClipboard(1); | |
| 1856 return; | |
| 1857 } | |
| 1858 if (dwKeyCode == 0x58 || dwKeyCode == 0x78) { | |
| 1859 DoClipboard(2); | |
| 1860 return; | |
| 1861 } | |
| 1862 if (dwKeyCode == 0x56 || dwKeyCode == 0x76) { | |
| 1863 DoClipboard(3); | |
| 1864 return; | |
| 1865 } | |
| 1866 } | |
| 1867 } | |
| 1868 } | 1605 } |
| 1869 if (MoveCaret != MC_MoveNone) | 1606 if (MoveCaret != MC_MoveNone) |
| 1870 m_pEdtEngine->MoveCaretPos(MoveCaret, bShift, bCtrl); | 1607 m_EdtEngine.MoveCaretPos(MoveCaret, bShift, bCtrl); |
| 1871 } | 1608 } |
| 1872 | 1609 |
| 1873 void IFWL_Edit::OnChar(CFWL_MsgKey* pMsg) { | 1610 void IFWL_Edit::OnChar(CFWL_MsgKey* pMsg) { |
| 1874 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || | 1611 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || |
| 1875 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { | 1612 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { |
| 1876 return; | 1613 return; |
| 1877 } | 1614 } |
| 1878 if (!m_pEdtEngine) | |
| 1879 return; | |
| 1880 | 1615 |
| 1881 int32_t iError = 0; | 1616 int32_t iError = 0; |
| 1882 FX_WCHAR c = (FX_WCHAR)pMsg->m_dwKeyCode; | 1617 FX_WCHAR c = (FX_WCHAR)pMsg->m_dwKeyCode; |
| 1883 int32_t nCaret = m_pEdtEngine->GetCaretPos(); | 1618 int32_t nCaret = m_EdtEngine.GetCaretPos(); |
| 1884 switch (c) { | 1619 switch (c) { |
| 1885 case FWL_VKEY_Back: | 1620 case FWL_VKEY_Back: |
| 1886 m_pEdtEngine->Delete(nCaret, true); | 1621 m_EdtEngine.Delete(nCaret, true); |
| 1887 break; | 1622 break; |
| 1888 case 0x0A: | 1623 case 0x0A: |
| 1889 break; | 1624 break; |
| 1890 case FWL_VKEY_Escape: | 1625 case FWL_VKEY_Escape: |
| 1891 break; | 1626 break; |
| 1892 case FWL_VKEY_Tab: { | 1627 case FWL_VKEY_Tab: { |
| 1893 iError = m_pEdtEngine->Insert(nCaret, L"\t", 1); | 1628 iError = m_EdtEngine.Insert(nCaret, L"\t", 1); |
| 1894 break; | 1629 break; |
| 1895 } | 1630 } |
| 1896 case FWL_VKEY_Return: { | 1631 case FWL_VKEY_Return: { |
| 1897 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_WantReturn) { | 1632 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_WantReturn) { |
| 1898 iError = m_pEdtEngine->Insert(nCaret, L"\n", 1); | 1633 iError = m_EdtEngine.Insert(nCaret, L"\n", 1); |
| 1899 } | 1634 } |
| 1900 break; | 1635 break; |
| 1901 } | 1636 } |
| 1902 default: { | 1637 default: { |
| 1903 if (!m_pWidgetMgr->IsFormDisabled()) { | 1638 if (!m_pWidgetMgr->IsFormDisabled()) { |
| 1904 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Number) { | 1639 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Number) { |
| 1905 if (((pMsg->m_dwKeyCode < FWL_VKEY_0) && | 1640 if (((pMsg->m_dwKeyCode < FWL_VKEY_0) && |
| 1906 (pMsg->m_dwKeyCode != 0x2E && pMsg->m_dwKeyCode != 0x2D)) || | 1641 (pMsg->m_dwKeyCode != 0x2E && pMsg->m_dwKeyCode != 0x2D)) || |
| 1907 pMsg->m_dwKeyCode > FWL_VKEY_9) { | 1642 pMsg->m_dwKeyCode > FWL_VKEY_9) { |
| 1908 break; | 1643 break; |
| 1909 } | 1644 } |
| 1910 if (!ValidateNumberChar(c)) | 1645 if (!ValidateNumberChar(c)) |
| 1911 break; | 1646 break; |
| 1912 } | 1647 } |
| 1913 } | 1648 } |
| 1914 #if (_FX_OS_ == _FX_MACOSX_) | 1649 #if (_FX_OS_ == _FX_MACOSX_) |
| 1915 if (pMsg->m_dwFlags & FWL_KEYFLAG_Command) | 1650 if (pMsg->m_dwFlags & FWL_KEYFLAG_Command) |
| 1916 #else | 1651 #else |
| 1917 if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) | 1652 if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) |
| 1918 #endif | 1653 #endif |
| 1919 { | 1654 { |
| 1920 break; | 1655 break; |
| 1921 } | 1656 } |
| 1922 iError = m_pEdtEngine->Insert(nCaret, &c, 1); | 1657 iError = m_EdtEngine.Insert(nCaret, &c, 1); |
| 1923 break; | 1658 break; |
| 1924 } | 1659 } |
| 1925 } | 1660 } |
| 1926 if (iError < 0) | 1661 if (iError < 0) |
| 1927 ProcessInsertError(iError); | 1662 ProcessInsertError(iError); |
| 1928 } | 1663 } |
| 1929 | 1664 |
| 1930 bool IFWL_Edit::OnScroll(IFWL_ScrollBar* pScrollBar, | 1665 bool IFWL_Edit::OnScroll(IFWL_ScrollBar* pScrollBar, |
| 1931 FWL_SCBCODE dwCode, | 1666 FWL_SCBCODE dwCode, |
| 1932 FX_FLOAT fPos) { | 1667 FX_FLOAT fPos) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1975 case FWL_SCBCODE::TrackPos: | 1710 case FWL_SCBCODE::TrackPos: |
| 1976 case FWL_SCBCODE::None: | 1711 case FWL_SCBCODE::None: |
| 1977 break; | 1712 break; |
| 1978 case FWL_SCBCODE::EndScroll: | 1713 case FWL_SCBCODE::EndScroll: |
| 1979 return false; | 1714 return false; |
| 1980 } | 1715 } |
| 1981 if (iCurPos != fPos) { | 1716 if (iCurPos != fPos) { |
| 1982 pScrollBar->SetPos(fPos); | 1717 pScrollBar->SetPos(fPos); |
| 1983 pScrollBar->SetTrackPos(fPos); | 1718 pScrollBar->SetTrackPos(fPos); |
| 1984 UpdateOffset(pScrollBar, fPos - iCurPos); | 1719 UpdateOffset(pScrollBar, fPos - iCurPos); |
| 1985 if (m_pEdtEngine) { | 1720 UpdateCaret(); |
| 1986 UpdateCaret(); | 1721 |
| 1987 } | |
| 1988 CFX_RectF rect; | 1722 CFX_RectF rect; |
| 1989 GetWidgetRect(rect); | 1723 GetWidgetRect(rect); |
| 1990 CFX_RectF rtInvalidate; | 1724 CFX_RectF rtInvalidate; |
| 1991 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); | 1725 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); |
| 1992 Repaint(&rtInvalidate); | 1726 Repaint(&rtInvalidate); |
| 1993 } | 1727 } |
| 1994 return true; | 1728 return true; |
| 1995 } | 1729 } |
| OLD | NEW |