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 "fpdfsdk/pdfwindow/PWL_EditCtrl.h" | 7 #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" |
8 | 8 |
9 #include "core/fpdfdoc/include/cpvt_section.h" | 9 #include "core/fpdfdoc/include/cpvt_section.h" |
10 #include "core/fpdfdoc/include/cpvt_word.h" | 10 #include "core/fpdfdoc/include/cpvt_word.h" |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 if (bVisible) { | 344 if (bVisible) { |
345 GetCaretInfo(ptHead, ptFoot); | 345 GetCaretInfo(ptHead, ptFoot); |
346 } | 346 } |
347 | 347 |
348 CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace(); | 348 CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace(); |
349 IOnSetCaret(bVisible, ptHead, ptFoot, wpTemp); | 349 IOnSetCaret(bVisible, ptHead, ptFoot, wpTemp); |
350 } | 350 } |
351 | 351 |
352 void CPWL_EditCtrl::GetCaretInfo(CFX_FloatPoint& ptHead, | 352 void CPWL_EditCtrl::GetCaretInfo(CFX_FloatPoint& ptHead, |
353 CFX_FloatPoint& ptFoot) const { | 353 CFX_FloatPoint& ptFoot) const { |
354 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { | 354 IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator(); |
355 pIterator->SetAt(m_pEdit->GetCaret()); | 355 pIterator->SetAt(m_pEdit->GetCaret()); |
356 CPVT_Word word; | 356 CPVT_Word word; |
357 CPVT_Line line; | 357 CPVT_Line line; |
358 if (pIterator->GetWord(word)) { | 358 if (pIterator->GetWord(word)) { |
359 ptHead.x = word.ptWord.x + word.fWidth; | 359 ptHead.x = word.ptWord.x + word.fWidth; |
360 ptHead.y = word.ptWord.y + word.fAscent; | 360 ptHead.y = word.ptWord.y + word.fAscent; |
361 ptFoot.x = word.ptWord.x + word.fWidth; | 361 ptFoot.x = word.ptWord.x + word.fWidth; |
362 ptFoot.y = word.ptWord.y + word.fDescent; | 362 ptFoot.y = word.ptWord.y + word.fDescent; |
363 } else if (pIterator->GetLine(line)) { | 363 } else if (pIterator->GetLine(line)) { |
364 ptHead.x = line.ptLine.x; | 364 ptHead.x = line.ptLine.x; |
365 ptHead.y = line.ptLine.y + line.fLineAscent; | 365 ptHead.y = line.ptLine.y + line.fLineAscent; |
366 ptFoot.x = line.ptLine.x; | 366 ptFoot.x = line.ptLine.x; |
367 ptFoot.y = line.ptLine.y + line.fLineDescent; | 367 ptFoot.y = line.ptLine.y + line.fLineDescent; |
368 } | |
369 } | 368 } |
370 } | 369 } |
371 | 370 |
372 void CPWL_EditCtrl::GetCaretPos(int32_t& x, int32_t& y) const { | 371 void CPWL_EditCtrl::GetCaretPos(int32_t& x, int32_t& y) const { |
373 CFX_FloatPoint ptHead(0, 0), ptFoot(0, 0); | 372 CFX_FloatPoint ptHead(0, 0), ptFoot(0, 0); |
374 | 373 |
375 GetCaretInfo(ptHead, ptFoot); | 374 GetCaretInfo(ptHead, ptFoot); |
376 | 375 |
377 PWLtoWnd(ptHead, x, y); | 376 PWLtoWnd(ptHead, x, y); |
378 } | 377 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 CFX_FloatPoint CPWL_EditCtrl::GetScrollPos() const { | 445 CFX_FloatPoint CPWL_EditCtrl::GetScrollPos() const { |
447 if (m_pEdit) | 446 if (m_pEdit) |
448 return m_pEdit->GetScrollPos(); | 447 return m_pEdit->GetScrollPos(); |
449 | 448 |
450 return CFX_FloatPoint(0.0f, 0.0f); | 449 return CFX_FloatPoint(0.0f, 0.0f); |
451 } | 450 } |
452 | 451 |
453 CPDF_Font* CPWL_EditCtrl::GetCaretFont() const { | 452 CPDF_Font* CPWL_EditCtrl::GetCaretFont() const { |
454 int32_t nFontIndex = 0; | 453 int32_t nFontIndex = 0; |
455 | 454 |
456 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { | 455 IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator(); |
457 pIterator->SetAt(m_pEdit->GetCaret()); | 456 pIterator->SetAt(m_pEdit->GetCaret()); |
458 CPVT_Word word; | 457 CPVT_Word word; |
459 CPVT_Section section; | 458 CPVT_Section section; |
460 if (pIterator->GetWord(word)) { | 459 if (pIterator->GetWord(word)) { |
461 nFontIndex = word.nFontIndex; | 460 nFontIndex = word.nFontIndex; |
462 } else if (HasFlag(PES_RICH)) { | 461 } else if (HasFlag(PES_RICH)) { |
463 if (pIterator->GetSection(section)) { | 462 if (pIterator->GetSection(section)) { |
464 nFontIndex = section.WordProps.nFontIndex; | 463 nFontIndex = section.WordProps.nFontIndex; |
465 } | |
466 } | 464 } |
467 } | 465 } |
468 | 466 |
469 if (IPVT_FontMap* pFontMap = GetFontMap()) | 467 if (IPVT_FontMap* pFontMap = GetFontMap()) |
470 return pFontMap->GetPDFFont(nFontIndex); | 468 return pFontMap->GetPDFFont(nFontIndex); |
471 | 469 |
472 return NULL; | 470 return NULL; |
473 } | 471 } |
474 | 472 |
475 FX_FLOAT CPWL_EditCtrl::GetCaretFontSize() const { | 473 FX_FLOAT CPWL_EditCtrl::GetCaretFontSize() const { |
476 FX_FLOAT fFontSize = GetFontSize(); | 474 FX_FLOAT fFontSize = GetFontSize(); |
477 | 475 |
478 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { | 476 IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator(); |
479 pIterator->SetAt(m_pEdit->GetCaret()); | 477 pIterator->SetAt(m_pEdit->GetCaret()); |
480 CPVT_Word word; | 478 CPVT_Word word; |
481 CPVT_Section section; | 479 CPVT_Section section; |
482 if (pIterator->GetWord(word)) { | 480 if (pIterator->GetWord(word)) { |
483 fFontSize = word.fFontSize; | 481 fFontSize = word.fFontSize; |
484 } else if (HasFlag(PES_RICH)) { | 482 } else if (HasFlag(PES_RICH)) { |
485 if (pIterator->GetSection(section)) { | 483 if (pIterator->GetSection(section)) { |
486 fFontSize = section.WordProps.fFontSize; | 484 fFontSize = section.WordProps.fFontSize; |
487 } | |
488 } | 485 } |
489 } | 486 } |
490 | 487 |
491 return fFontSize; | 488 return fFontSize; |
492 } | 489 } |
493 | 490 |
494 void CPWL_EditCtrl::SetText(const FX_WCHAR* csText) { | 491 void CPWL_EditCtrl::SetText(const FX_WCHAR* csText) { |
495 m_pEdit->SetText(csText); | 492 m_pEdit->SetText(csText); |
496 } | 493 } |
497 | 494 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar); | 617 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar); |
621 return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd)); | 618 return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd)); |
622 } | 619 } |
623 | 620 |
624 void CPWL_EditCtrl::SetReadyToInput() { | 621 void CPWL_EditCtrl::SetReadyToInput() { |
625 if (m_bMouseDown) { | 622 if (m_bMouseDown) { |
626 ReleaseCapture(); | 623 ReleaseCapture(); |
627 m_bMouseDown = FALSE; | 624 m_bMouseDown = FALSE; |
628 } | 625 } |
629 } | 626 } |
OLD | NEW |