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 "../../include/pdfwindow/PDFWindow.h" | 7 #include "../../include/pdfwindow/PDFWindow.h" |
8 #include "../../include/pdfwindow/PWL_Wnd.h" | 8 #include "../../include/pdfwindow/PWL_Wnd.h" |
9 #include "../../include/pdfwindow/PWL_EditCtrl.h" | 9 #include "../../include/pdfwindow/PWL_EditCtrl.h" |
10 #include "../../include/pdfwindow/PWL_ScrollBar.h" | 10 #include "../../include/pdfwindow/PWL_ScrollBar.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 pSH->SetCursor(FXCT_HBEAM); | 74 pSH->SetCursor(FXCT_HBEAM); |
75 } | 75 } |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 void CPWL_EditCtrl::RePosChildWnd() | 79 void CPWL_EditCtrl::RePosChildWnd() |
80 { | 80 { |
81 m_pEdit->SetPlateRect(GetClientRect()); | 81 m_pEdit->SetPlateRect(GetClientRect()); |
82 } | 82 } |
83 | 83 |
84 void CPWL_EditCtrl::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX_
INTPTR lParam) | 84 void CPWL_EditCtrl::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intp
tr_t lParam) |
85 { | 85 { |
86 CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam); | 86 CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam); |
87 | 87 |
88 switch (msg) | 88 switch (msg) |
89 { | 89 { |
90 case PNM_SETSCROLLINFO: | 90 case PNM_SETSCROLLINFO: |
91 switch (wParam) | 91 switch (wParam) |
92 { | 92 { |
93 case SBT_VSCROLL: | 93 case SBT_VSCROLL: |
94 if (CPWL_Wnd * pChild = GetVScrollBar()) | 94 if (CPWL_Wnd * pChild = GetVScrollBar()) |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 else if (pIterator->GetLine(line)) | 402 else if (pIterator->GetLine(line)) |
403 { | 403 { |
404 ptHead.x = line.ptLine.x; | 404 ptHead.x = line.ptLine.x; |
405 ptHead.y = line.ptLine.y + line.fLineAscent; | 405 ptHead.y = line.ptLine.y + line.fLineAscent; |
406 ptFoot.x = line.ptLine.x; | 406 ptFoot.x = line.ptLine.x; |
407 ptFoot.y = line.ptLine.y + line.fLineDescent; | 407 ptFoot.y = line.ptLine.y + line.fLineDescent; |
408 } | 408 } |
409 } | 409 } |
410 } | 410 } |
411 | 411 |
412 void CPWL_EditCtrl::GetCaretPos(FX_INT32& x, FX_INT32& y) const | 412 void CPWL_EditCtrl::GetCaretPos(int32_t& x, int32_t& y) const |
413 { | 413 { |
414 CPDF_Point ptHead(0,0), ptFoot(0,0); | 414 CPDF_Point ptHead(0,0), ptFoot(0,0); |
415 | 415 |
416 GetCaretInfo(ptHead,ptFoot); | 416 GetCaretInfo(ptHead,ptFoot); |
417 | 417 |
418 PWLtoWnd(ptHead, x, y); | 418 PWLtoWnd(ptHead, x, y); |
419 } | 419 } |
420 | 420 |
421 void CPWL_EditCtrl::SetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, const
CPDF_Point & ptFoot) | 421 void CPWL_EditCtrl::SetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, const
CPDF_Point & ptFoot) |
422 { | 422 { |
423 if (m_pEditCaret) | 423 if (m_pEditCaret) |
424 { | 424 { |
425 if (!IsFocused() || m_pEdit->IsSelected()) | 425 if (!IsFocused() || m_pEdit->IsSelected()) |
426 bVisible = FALSE; | 426 bVisible = FALSE; |
427 | 427 |
428 m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot); | 428 m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot); |
429 } | 429 } |
430 } | 430 } |
431 | 431 |
432 FX_BOOL CPWL_EditCtrl::IsModified() const | 432 FX_BOOL CPWL_EditCtrl::IsModified() const |
433 { | 433 { |
434 return m_pEdit->IsModified(); | 434 return m_pEdit->IsModified(); |
435 } | 435 } |
436 | 436 |
437 CFX_WideString CPWL_EditCtrl::GetText() const | 437 CFX_WideString CPWL_EditCtrl::GetText() const |
438 { | 438 { |
439 return m_pEdit->GetText(); | 439 return m_pEdit->GetText(); |
440 } | 440 } |
441 | 441 |
442 void CPWL_EditCtrl::SetSel(FX_INT32 nStartChar,FX_INT32 nEndChar) | 442 void CPWL_EditCtrl::SetSel(int32_t nStartChar,int32_t nEndChar) |
443 { | 443 { |
444 m_pEdit->SetSel(nStartChar, nEndChar); | 444 m_pEdit->SetSel(nStartChar, nEndChar); |
445 } | 445 } |
446 | 446 |
447 void CPWL_EditCtrl::GetSel(FX_INT32 & nStartChar, FX_INT32 & nEndChar ) const | 447 void CPWL_EditCtrl::GetSel(int32_t & nStartChar, int32_t & nEndChar ) const |
448 { | 448 { |
449 m_pEdit->GetSel(nStartChar, nEndChar); | 449 m_pEdit->GetSel(nStartChar, nEndChar); |
450 } | 450 } |
451 | 451 |
452 void CPWL_EditCtrl::Clear() | 452 void CPWL_EditCtrl::Clear() |
453 { | 453 { |
454 if (!IsReadOnly()) | 454 if (!IsReadOnly()) |
455 m_pEdit->Clear(); | 455 m_pEdit->Clear(); |
456 } | 456 } |
457 | 457 |
458 void CPWL_EditCtrl::SelectAll() | 458 void CPWL_EditCtrl::SelectAll() |
459 { | 459 { |
460 m_pEdit->SelectAll(); | 460 m_pEdit->SelectAll(); |
461 } | 461 } |
462 | 462 |
463 void CPWL_EditCtrl::Paint() | 463 void CPWL_EditCtrl::Paint() |
464 { | 464 { |
465 if (m_pEdit) | 465 if (m_pEdit) |
466 m_pEdit->Paint(); | 466 m_pEdit->Paint(); |
467 } | 467 } |
468 | 468 |
469 void CPWL_EditCtrl::EnableRefresh(FX_BOOL bRefresh) | 469 void CPWL_EditCtrl::EnableRefresh(FX_BOOL bRefresh) |
470 { | 470 { |
471 if (m_pEdit) | 471 if (m_pEdit) |
472 m_pEdit->EnableRefresh(bRefresh); | 472 m_pEdit->EnableRefresh(bRefresh); |
473 } | 473 } |
474 | 474 |
475 FX_INT32 CPWL_EditCtrl::GetCaret() const | 475 int32_t CPWL_EditCtrl::GetCaret() const |
476 { | 476 { |
477 if (m_pEdit) | 477 if (m_pEdit) |
478 return m_pEdit->GetCaret(); | 478 return m_pEdit->GetCaret(); |
479 | 479 |
480 return -1; | 480 return -1; |
481 } | 481 } |
482 | 482 |
483 void CPWL_EditCtrl::SetCaret(FX_INT32 nPos) | 483 void CPWL_EditCtrl::SetCaret(int32_t nPos) |
484 { | 484 { |
485 if (m_pEdit) | 485 if (m_pEdit) |
486 m_pEdit->SetCaret(nPos); | 486 m_pEdit->SetCaret(nPos); |
487 } | 487 } |
488 | 488 |
489 FX_INT32 CPWL_EditCtrl::GetTotalWords() const | 489 int32_t CPWL_EditCtrl::GetTotalWords() const |
490 { | 490 { |
491 if (m_pEdit) | 491 if (m_pEdit) |
492 return m_pEdit->GetTotalWords(); | 492 return m_pEdit->GetTotalWords(); |
493 | 493 |
494 return 0; | 494 return 0; |
495 } | 495 } |
496 | 496 |
497 void CPWL_EditCtrl::SetScrollPos(const CPDF_Point& point) | 497 void CPWL_EditCtrl::SetScrollPos(const CPDF_Point& point) |
498 { | 498 { |
499 if (m_pEdit) | 499 if (m_pEdit) |
500 m_pEdit->SetScrollPos(point); | 500 m_pEdit->SetScrollPos(point); |
501 } | 501 } |
502 | 502 |
503 CPDF_Point CPWL_EditCtrl::GetScrollPos() const | 503 CPDF_Point CPWL_EditCtrl::GetScrollPos() const |
504 { | 504 { |
505 if (m_pEdit) | 505 if (m_pEdit) |
506 return m_pEdit->GetScrollPos(); | 506 return m_pEdit->GetScrollPos(); |
507 | 507 |
508 return CPDF_Point(0.0f, 0.0f); | 508 return CPDF_Point(0.0f, 0.0f); |
509 } | 509 } |
510 | 510 |
511 CPDF_Font * CPWL_EditCtrl::GetCaretFont() const | 511 CPDF_Font * CPWL_EditCtrl::GetCaretFont() const |
512 { | 512 { |
513 » FX_INT32 nFontIndex = 0; | 513 » int32_t nFontIndex = 0; |
514 | 514 |
515 if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator()) | 515 if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator()) |
516 { | 516 { |
517 pIterator->SetAt(m_pEdit->GetCaret()); | 517 pIterator->SetAt(m_pEdit->GetCaret()); |
518 CPVT_Word word; | 518 CPVT_Word word; |
519 CPVT_Section section; | 519 CPVT_Section section; |
520 if (pIterator->GetWord(word)) | 520 if (pIterator->GetWord(word)) |
521 { | 521 { |
522 nFontIndex = word.nFontIndex; | 522 nFontIndex = word.nFontIndex; |
523 } | 523 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 void CPWL_EditCtrl::ShowVScrollBar(FX_BOOL bShow) | 581 void CPWL_EditCtrl::ShowVScrollBar(FX_BOOL bShow) |
582 { | 582 { |
583 } | 583 } |
584 | 584 |
585 void CPWL_EditCtrl::InsertText(FX_LPCWSTR csText) | 585 void CPWL_EditCtrl::InsertText(FX_LPCWSTR csText) |
586 { | 586 { |
587 if (!IsReadOnly()) | 587 if (!IsReadOnly()) |
588 m_pEdit->InsertText(csText); | 588 m_pEdit->InsertText(csText); |
589 } | 589 } |
590 | 590 |
591 void CPWL_EditCtrl::InsertWord(FX_WORD word, FX_INT32 nCharset) | 591 void CPWL_EditCtrl::InsertWord(FX_WORD word, int32_t nCharset) |
592 { | 592 { |
593 if (!IsReadOnly()) | 593 if (!IsReadOnly()) |
594 m_pEdit->InsertWord(word, nCharset); | 594 m_pEdit->InsertWord(word, nCharset); |
595 } | 595 } |
596 | 596 |
597 void CPWL_EditCtrl::InsertReturn() | 597 void CPWL_EditCtrl::InsertReturn() |
598 { | 598 { |
599 if (!IsReadOnly()) | 599 if (!IsReadOnly()) |
600 m_pEdit->InsertReturn(); | 600 m_pEdit->InsertReturn(); |
601 } | 601 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639
FX_FLOAT fSmallStep, FX_FLOAT fBigStep) | 639
FX_FLOAT fSmallStep, FX_FLOAT fBigStep) |
640 { | 640 { |
641 PWL_SCROLL_INFO Info; | 641 PWL_SCROLL_INFO Info; |
642 | 642 |
643 Info.fPlateWidth = fPlateMax - fPlateMin; | 643 Info.fPlateWidth = fPlateMax - fPlateMin; |
644 Info.fContentMin = fContentMin; | 644 Info.fContentMin = fContentMin; |
645 Info.fContentMax = fContentMax; | 645 Info.fContentMax = fContentMax; |
646 Info.fSmallStep = fSmallStep; | 646 Info.fSmallStep = fSmallStep; |
647 Info.fBigStep = fBigStep; | 647 Info.fBigStep = fBigStep; |
648 | 648 |
649 » this->OnNotify(this,PNM_SETSCROLLINFO,SBT_VSCROLL,(FX_INTPTR)&Info); | 649 » this->OnNotify(this,PNM_SETSCROLLINFO,SBT_VSCROLL,(intptr_t)&Info); |
650 | 650 |
651 // PWL_TRACE("set scroll info:%f\n",fContentMax - fContentMin); | 651 // PWL_TRACE("set scroll info:%f\n",fContentMax - fContentMin); |
652 | 652 |
653 if (IsFloatBigger(Info.fPlateWidth,Info.fContentMax-Info.fContentMin) | 653 if (IsFloatBigger(Info.fPlateWidth,Info.fContentMax-Info.fContentMin) |
654 || IsFloatEqual(Info.fPlateWidth,Info.fContentMax-Info.fContentM
in)) | 654 || IsFloatEqual(Info.fPlateWidth,Info.fContentMax-Info.fContentM
in)) |
655 { | 655 { |
656 this->ShowVScrollBar(FALSE); | 656 this->ShowVScrollBar(FALSE); |
657 } | 657 } |
658 else | 658 else |
659 { | 659 { |
660 this->ShowVScrollBar(TRUE); | 660 this->ShowVScrollBar(TRUE); |
661 } | 661 } |
662 } | 662 } |
663 | 663 |
664 void CPWL_EditCtrl::IOnSetScrollPosY(FX_FLOAT fy) | 664 void CPWL_EditCtrl::IOnSetScrollPosY(FX_FLOAT fy) |
665 { | 665 { |
666 // PWL_TRACE("set scroll position:%f\n",fy); | 666 // PWL_TRACE("set scroll position:%f\n",fy); |
667 » this->OnNotify(this,PNM_SETSCROLLPOS,SBT_VSCROLL,(FX_INTPTR)&fy); | 667 » this->OnNotify(this,PNM_SETSCROLLPOS,SBT_VSCROLL,(intptr_t)&fy); |
668 } | 668 } |
669 | 669 |
670 void CPWL_EditCtrl::IOnSetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, con
st CPDF_Point & ptFoot, const CPVT_WordPlace& place) | 670 void CPWL_EditCtrl::IOnSetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, con
st CPDF_Point & ptFoot, const CPVT_WordPlace& place) |
671 { | 671 { |
672 PWL_CARET_INFO cInfo; | 672 PWL_CARET_INFO cInfo; |
673 cInfo.bVisible = bVisible; | 673 cInfo.bVisible = bVisible; |
674 cInfo.ptHead = ptHead; | 674 cInfo.ptHead = ptHead; |
675 cInfo.ptFoot = ptFoot; | 675 cInfo.ptFoot = ptFoot; |
676 | 676 |
677 » this->OnNotify(this,PNM_SETCARETINFO,(FX_INTPTR)&cInfo,(FX_INTPTR)NULL); | 677 » this->OnNotify(this,PNM_SETCARETINFO,(intptr_t)&cInfo,(intptr_t)NULL); |
678 } | 678 } |
679 | 679 |
680 void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps & secProps, const CPVT_Wo
rdProps & wordProps) | 680 void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps & secProps, const CPVT_Wo
rdProps & wordProps) |
681 { | 681 { |
682 } | 682 } |
683 | 683 |
684 void CPWL_EditCtrl::IOnContentChange(const CPDF_Rect& rcContent) | 684 void CPWL_EditCtrl::IOnContentChange(const CPDF_Rect& rcContent) |
685 { | 685 { |
686 if (this->IsValid()) | 686 if (this->IsValid()) |
687 { | 687 { |
688 if (m_pEditNotify) | 688 if (m_pEditNotify) |
689 { | 689 { |
690 m_pEditNotify->OnContentChange(rcContent); | 690 m_pEditNotify->OnContentChange(rcContent); |
691 } | 691 } |
692 } | 692 } |
693 } | 693 } |
694 | 694 |
695 void CPWL_EditCtrl::IOnInvalidateRect(CPDF_Rect * pRect) | 695 void CPWL_EditCtrl::IOnInvalidateRect(CPDF_Rect * pRect) |
696 { | 696 { |
697 this->InvalidateRect(pRect); | 697 this->InvalidateRect(pRect); |
698 } | 698 } |
699 | 699 |
700 FX_INT32 CPWL_EditCtrl::GetCharSet() const | 700 int32_t CPWL_EditCtrl::GetCharSet() const |
701 { | 701 { |
702 if (m_nCharSet < 0) | 702 if (m_nCharSet < 0) |
703 return DEFAULT_CHARSET; | 703 return DEFAULT_CHARSET; |
704 else | 704 else |
705 return m_nCharSet; | 705 return m_nCharSet; |
706 } | 706 } |
707 | 707 |
708 void CPWL_EditCtrl::GetTextRange(const CPDF_Rect& rect, FX_INT32 & nStartChar, F
X_INT32 & nEndChar) const | 708 void CPWL_EditCtrl::GetTextRange(const CPDF_Rect& rect, int32_t & nStartChar, in
t32_t & nEndChar) const |
709 { | 709 { |
710 nStartChar = m_pEdit->WordPlaceToWordIndex(m_pEdit->SearchWordPlace(CPDF
_Point(rect.left, rect.top))); | 710 nStartChar = m_pEdit->WordPlaceToWordIndex(m_pEdit->SearchWordPlace(CPDF
_Point(rect.left, rect.top))); |
711 nEndChar = m_pEdit->WordPlaceToWordIndex(m_pEdit->SearchWordPlace(CPDF_P
oint(rect.right, rect.bottom))); | 711 nEndChar = m_pEdit->WordPlaceToWordIndex(m_pEdit->SearchWordPlace(CPDF_P
oint(rect.right, rect.bottom))); |
712 } | 712 } |
713 | 713 |
714 CFX_WideString CPWL_EditCtrl::GetText(FX_INT32 & nStartChar, FX_INT32 & nEndChar
) const | 714 CFX_WideString CPWL_EditCtrl::GetText(int32_t & nStartChar, int32_t & nEndChar)
const |
715 { | 715 { |
716 CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStartChar); | 716 CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStartChar); |
717 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar); | 717 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar); |
718 return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd)); | 718 return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd)); |
719 } | 719 } |
720 | 720 |
721 void CPWL_EditCtrl::SetReadyToInput() | 721 void CPWL_EditCtrl::SetReadyToInput() |
722 { | 722 { |
723 if (m_bMouseDown) | 723 if (m_bMouseDown) |
724 { | 724 { |
725 ReleaseCapture(); | 725 ReleaseCapture(); |
726 m_bMouseDown = FALSE; | 726 m_bMouseDown = FALSE; |
727 } | 727 } |
728 } | 728 } |
OLD | NEW |