Chromium Code Reviews| 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/fxedit/include/fxet_edit.h" | 7 #include "fpdfsdk/fxedit/include/fxet_edit.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 762 m_pEdit->SelectNone(); | 762 m_pEdit->SelectNone(); |
| 763 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); | 763 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); |
| 764 m_pEdit->Clear(FALSE, TRUE); | 764 m_pEdit->Clear(FALSE, TRUE); |
| 765 } | 765 } |
| 766 } | 766 } |
| 767 | 767 |
| 768 void CFXEU_Clear::Undo() { | 768 void CFXEU_Clear::Undo() { |
| 769 if (m_pEdit) { | 769 if (m_pEdit) { |
| 770 m_pEdit->SelectNone(); | 770 m_pEdit->SelectNone(); |
| 771 m_pEdit->SetCaret(m_wrSel.BeginPos); | 771 m_pEdit->SetCaret(m_wrSel.BeginPos); |
| 772 m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, nullptr, nullptr, | 772 m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, FALSE, TRUE); |
| 773 FALSE, TRUE); | |
| 774 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); | 773 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); |
| 775 } | 774 } |
| 776 } | 775 } |
| 777 | 776 |
| 778 CFXEU_InsertText::CFXEU_InsertText(CFX_Edit* pEdit, | 777 CFXEU_InsertText::CFXEU_InsertText(CFX_Edit* pEdit, |
| 779 const CPVT_WordPlace& wpOldPlace, | 778 const CPVT_WordPlace& wpOldPlace, |
| 780 const CPVT_WordPlace& wpNewPlace, | 779 const CPVT_WordPlace& wpNewPlace, |
| 781 const CFX_WideString& swText, | 780 const CFX_WideString& swText, |
| 782 int32_t charset, | 781 int32_t charset) |
| 783 const CPVT_SecProps* pSecProps, | |
| 784 const CPVT_WordProps* pWordProps) | |
| 785 : m_pEdit(pEdit), | 782 : m_pEdit(pEdit), |
| 786 m_wpOld(wpOldPlace), | 783 m_wpOld(wpOldPlace), |
| 787 m_wpNew(wpNewPlace), | 784 m_wpNew(wpNewPlace), |
| 788 m_swText(swText), | 785 m_swText(swText), |
| 789 m_nCharset(charset), | 786 m_nCharset(charset) {} |
| 790 m_SecProps(), | |
| 791 m_WordProps() { | |
| 792 if (pSecProps) | |
| 793 m_SecProps = *pSecProps; | |
| 794 if (pWordProps) | |
| 795 m_WordProps = *pWordProps; | |
| 796 } | |
| 797 | 787 |
| 798 CFXEU_InsertText::~CFXEU_InsertText() {} | 788 CFXEU_InsertText::~CFXEU_InsertText() {} |
| 799 | 789 |
| 800 void CFXEU_InsertText::Redo() { | 790 void CFXEU_InsertText::Redo() { |
| 801 if (m_pEdit && IsLast()) { | 791 if (m_pEdit && IsLast()) { |
| 802 m_pEdit->SelectNone(); | 792 m_pEdit->SelectNone(); |
| 803 m_pEdit->SetCaret(m_wpOld); | 793 m_pEdit->SetCaret(m_wpOld); |
| 804 m_pEdit->InsertText(m_swText.c_str(), m_nCharset, &m_SecProps, &m_WordProps, | 794 m_pEdit->InsertText(m_swText.c_str(), m_nCharset, FALSE, TRUE); |
|
Lei Zhang
2016/07/13 19:35:15
Can you help convince me this is safe to remove?
dsinclair
2016/07/14 14:16:53
CFXEU_InsertText is created in CFX_Edit::InsertTex
| |
| 805 FALSE, TRUE); | |
| 806 } | 795 } |
| 807 } | 796 } |
| 808 | 797 |
| 809 void CFXEU_InsertText::Undo() { | 798 void CFXEU_InsertText::Undo() { |
| 810 if (m_pEdit) { | 799 if (m_pEdit) { |
| 811 m_pEdit->SelectNone(); | 800 m_pEdit->SelectNone(); |
| 812 m_pEdit->SetSel(m_wpOld, m_wpNew); | 801 m_pEdit->SetSel(m_wpOld, m_wpNew); |
| 813 m_pEdit->Clear(FALSE, TRUE); | 802 m_pEdit->Clear(FALSE, TRUE); |
| 814 } | 803 } |
| 815 } | 804 } |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1496 } | 1485 } |
| 1497 | 1486 |
| 1498 CPDF_VariableText* CFX_Edit::GetVariableText() { | 1487 CPDF_VariableText* CFX_Edit::GetVariableText() { |
| 1499 return m_pVT.get(); | 1488 return m_pVT.get(); |
| 1500 } | 1489 } |
| 1501 | 1490 |
| 1502 IPVT_FontMap* CFX_Edit::GetFontMap() { | 1491 IPVT_FontMap* CFX_Edit::GetFontMap() { |
| 1503 return m_pVTProvider ? m_pVTProvider->GetFontMap() : nullptr; | 1492 return m_pVTProvider ? m_pVTProvider->GetFontMap() : nullptr; |
| 1504 } | 1493 } |
| 1505 | 1494 |
| 1506 void CFX_Edit::SetPlateRect(const CFX_FloatRect& rect, FX_BOOL bPaint) { | 1495 void CFX_Edit::SetPlateRect(const CFX_FloatRect& rect) { |
| 1507 m_pVT->SetPlateRect(rect); | 1496 m_pVT->SetPlateRect(rect); |
| 1508 m_ptScrollPos = CFX_FloatPoint(rect.left, rect.top); | 1497 m_ptScrollPos = CFX_FloatPoint(rect.left, rect.top); |
| 1509 if (bPaint) | 1498 Paint(); |
| 1510 Paint(); | |
| 1511 } | 1499 } |
| 1512 | 1500 |
| 1513 void CFX_Edit::SetAlignmentH(int32_t nFormat, FX_BOOL bPaint) { | 1501 void CFX_Edit::SetAlignmentH(int32_t nFormat, FX_BOOL bPaint) { |
| 1514 m_pVT->SetAlignment(nFormat); | 1502 m_pVT->SetAlignment(nFormat); |
| 1515 if (bPaint) | 1503 if (bPaint) |
| 1516 Paint(); | 1504 Paint(); |
| 1517 } | 1505 } |
| 1518 | 1506 |
| 1519 void CFX_Edit::SetAlignmentV(int32_t nFormat, FX_BOOL bPaint) { | 1507 void CFX_Edit::SetAlignmentV(int32_t nFormat, FX_BOOL bPaint) { |
| 1520 m_nAlignment = nFormat; | 1508 m_nAlignment = nFormat; |
| 1521 if (bPaint) | 1509 if (bPaint) |
| 1522 Paint(); | 1510 Paint(); |
| 1523 } | 1511 } |
| 1524 | 1512 |
| 1525 void CFX_Edit::SetPasswordChar(uint16_t wSubWord, FX_BOOL bPaint) { | 1513 void CFX_Edit::SetPasswordChar(uint16_t wSubWord, FX_BOOL bPaint) { |
| 1526 m_pVT->SetPasswordChar(wSubWord); | 1514 m_pVT->SetPasswordChar(wSubWord); |
| 1527 if (bPaint) | 1515 if (bPaint) |
| 1528 Paint(); | 1516 Paint(); |
| 1529 } | 1517 } |
| 1530 | 1518 |
| 1531 void CFX_Edit::SetLimitChar(int32_t nLimitChar, FX_BOOL bPaint) { | 1519 void CFX_Edit::SetLimitChar(int32_t nLimitChar) { |
| 1532 m_pVT->SetLimitChar(nLimitChar); | 1520 m_pVT->SetLimitChar(nLimitChar); |
| 1533 if (bPaint) | 1521 Paint(); |
| 1534 Paint(); | |
| 1535 } | 1522 } |
| 1536 | 1523 |
| 1537 void CFX_Edit::SetCharArray(int32_t nCharArray, FX_BOOL bPaint) { | 1524 void CFX_Edit::SetCharArray(int32_t nCharArray) { |
| 1538 m_pVT->SetCharArray(nCharArray); | 1525 m_pVT->SetCharArray(nCharArray); |
| 1539 if (bPaint) | 1526 Paint(); |
| 1540 Paint(); | |
| 1541 } | 1527 } |
| 1542 | 1528 |
| 1543 void CFX_Edit::SetCharSpace(FX_FLOAT fCharSpace, FX_BOOL bPaint) { | 1529 void CFX_Edit::SetCharSpace(FX_FLOAT fCharSpace) { |
| 1544 m_pVT->SetCharSpace(fCharSpace); | 1530 m_pVT->SetCharSpace(fCharSpace); |
| 1545 if (bPaint) | 1531 Paint(); |
| 1546 Paint(); | |
| 1547 } | |
| 1548 | |
| 1549 void CFX_Edit::SetHorzScale(int32_t nHorzScale, FX_BOOL bPaint) { | |
| 1550 m_pVT->SetHorzScale(nHorzScale); | |
| 1551 if (bPaint) | |
| 1552 Paint(); | |
| 1553 } | 1532 } |
| 1554 | 1533 |
| 1555 void CFX_Edit::SetMultiLine(FX_BOOL bMultiLine, FX_BOOL bPaint) { | 1534 void CFX_Edit::SetMultiLine(FX_BOOL bMultiLine, FX_BOOL bPaint) { |
| 1556 m_pVT->SetMultiLine(bMultiLine); | 1535 m_pVT->SetMultiLine(bMultiLine); |
| 1557 if (bPaint) | 1536 if (bPaint) |
| 1558 Paint(); | 1537 Paint(); |
| 1559 } | 1538 } |
| 1560 | 1539 |
| 1561 void CFX_Edit::SetAutoReturn(FX_BOOL bAuto, FX_BOOL bPaint) { | 1540 void CFX_Edit::SetAutoReturn(FX_BOOL bAuto, FX_BOOL bPaint) { |
| 1562 m_pVT->SetAutoReturn(bAuto); | 1541 m_pVT->SetAutoReturn(bAuto); |
| 1563 if (bPaint) | 1542 if (bPaint) |
| 1564 Paint(); | 1543 Paint(); |
| 1565 } | 1544 } |
| 1566 | 1545 |
| 1567 void CFX_Edit::SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint) { | |
| 1568 m_pVT->SetLineLeading(fLineLeading); | |
| 1569 if (bPaint) | |
| 1570 Paint(); | |
| 1571 } | |
| 1572 | |
| 1573 void CFX_Edit::SetAutoFontSize(FX_BOOL bAuto, FX_BOOL bPaint) { | 1546 void CFX_Edit::SetAutoFontSize(FX_BOOL bAuto, FX_BOOL bPaint) { |
| 1574 m_pVT->SetAutoFontSize(bAuto); | 1547 m_pVT->SetAutoFontSize(bAuto); |
| 1575 if (bPaint) | 1548 if (bPaint) |
| 1576 Paint(); | 1549 Paint(); |
| 1577 } | 1550 } |
| 1578 | 1551 |
| 1579 void CFX_Edit::SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint) { | 1552 void CFX_Edit::SetFontSize(FX_FLOAT fFontSize) { |
| 1580 m_pVT->SetFontSize(fFontSize); | 1553 m_pVT->SetFontSize(fFontSize); |
| 1581 if (bPaint) | 1554 Paint(); |
| 1582 Paint(); | |
| 1583 } | 1555 } |
| 1584 | 1556 |
| 1585 void CFX_Edit::SetAutoScroll(FX_BOOL bAuto, FX_BOOL bPaint) { | 1557 void CFX_Edit::SetAutoScroll(FX_BOOL bAuto, FX_BOOL bPaint) { |
| 1586 m_bEnableScroll = bAuto; | 1558 m_bEnableScroll = bAuto; |
| 1587 if (bPaint) | 1559 if (bPaint) |
| 1588 Paint(); | 1560 Paint(); |
| 1589 } | 1561 } |
| 1590 | 1562 |
| 1591 void CFX_Edit::SetTextOverflow(FX_BOOL bAllowed, FX_BOOL bPaint) { | 1563 void CFX_Edit::SetTextOverflow(FX_BOOL bAllowed, FX_BOOL bPaint) { |
| 1592 m_bEnableOverflow = bAllowed; | 1564 m_bEnableOverflow = bAllowed; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1615 void CFX_Edit::SetSel(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { | 1587 void CFX_Edit::SetSel(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { |
| 1616 if (m_pVT->IsValid()) { | 1588 if (m_pVT->IsValid()) { |
| 1617 SelectNone(); | 1589 SelectNone(); |
| 1618 | 1590 |
| 1619 m_SelState.Set(begin, end); | 1591 m_SelState.Set(begin, end); |
| 1620 | 1592 |
| 1621 SetCaret(m_SelState.EndPos); | 1593 SetCaret(m_SelState.EndPos); |
| 1622 | 1594 |
| 1623 if (m_SelState.IsExist()) { | 1595 if (m_SelState.IsExist()) { |
| 1624 ScrollToCaret(); | 1596 ScrollToCaret(); |
| 1625 CPVT_WordRange wr(m_SelState.BeginPos, m_SelState.EndPos); | 1597 Refresh(); |
| 1626 Refresh(RP_OPTIONAL, &wr); | |
| 1627 SetCaretInfo(); | 1598 SetCaretInfo(); |
| 1628 } else { | 1599 } else { |
| 1629 ScrollToCaret(); | 1600 ScrollToCaret(); |
| 1630 SetCaretInfo(); | 1601 SetCaretInfo(); |
| 1631 } | 1602 } |
| 1632 } | 1603 } |
| 1633 } | 1604 } |
| 1634 | 1605 |
| 1635 void CFX_Edit::GetSel(int32_t& nStartChar, int32_t& nEndChar) const { | 1606 void CFX_Edit::GetSel(int32_t& nStartChar, int32_t& nEndChar) const { |
| 1636 nStartChar = -1; | 1607 nStartChar = -1; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1755 | 1726 |
| 1756 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) { | 1727 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) { |
| 1757 wrRet.EndPos = wr2.EndPos; | 1728 wrRet.EndPos = wr2.EndPos; |
| 1758 } else { | 1729 } else { |
| 1759 wrRet.EndPos = wr1.EndPos; | 1730 wrRet.EndPos = wr1.EndPos; |
| 1760 } | 1731 } |
| 1761 | 1732 |
| 1762 return wrRet; | 1733 return wrRet; |
| 1763 } | 1734 } |
| 1764 | 1735 |
| 1765 void CFX_Edit::SetText(const FX_WCHAR* text, | 1736 void CFX_Edit::SetText(const FX_WCHAR* text) { |
| 1766 int32_t charset, | 1737 Empty(); |
| 1767 const CPVT_SecProps* pSecProps, | 1738 DoInsertText(CPVT_WordPlace(0, 0, -1), text, DEFAULT_CHARSET); |
| 1768 const CPVT_WordProps* pWordProps) { | 1739 Paint(); |
| 1769 SetText(text, charset, pSecProps, pWordProps, TRUE, TRUE); | |
| 1770 } | 1740 } |
| 1771 | 1741 |
| 1772 FX_BOOL CFX_Edit::InsertWord(uint16_t word, | 1742 FX_BOOL CFX_Edit::InsertWord(uint16_t word, int32_t charset) { |
| 1773 int32_t charset, | 1743 return InsertWord(word, charset, nullptr, TRUE, TRUE); |
| 1774 const CPVT_WordProps* pWordProps) { | |
| 1775 return InsertWord(word, charset, pWordProps, TRUE, TRUE); | |
| 1776 } | 1744 } |
| 1777 | 1745 |
| 1778 FX_BOOL CFX_Edit::InsertReturn(const CPVT_SecProps* pSecProps, | 1746 FX_BOOL CFX_Edit::InsertReturn() { |
| 1779 const CPVT_WordProps* pWordProps) { | 1747 return InsertReturn(nullptr, nullptr, TRUE, TRUE); |
| 1780 return InsertReturn(pSecProps, pWordProps, TRUE, TRUE); | |
| 1781 } | 1748 } |
| 1782 | 1749 |
| 1783 FX_BOOL CFX_Edit::Backspace() { | 1750 FX_BOOL CFX_Edit::Backspace() { |
| 1784 return Backspace(TRUE, TRUE); | 1751 return Backspace(TRUE, TRUE); |
| 1785 } | 1752 } |
| 1786 | 1753 |
| 1787 FX_BOOL CFX_Edit::Delete() { | 1754 FX_BOOL CFX_Edit::Delete() { |
| 1788 return Delete(TRUE, TRUE); | 1755 return Delete(TRUE, TRUE); |
| 1789 } | 1756 } |
| 1790 | 1757 |
| 1791 FX_BOOL CFX_Edit::Clear() { | 1758 FX_BOOL CFX_Edit::Clear() { |
| 1792 return Clear(TRUE, TRUE); | 1759 return Clear(TRUE, TRUE); |
| 1793 } | 1760 } |
| 1794 | 1761 |
| 1795 FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, | 1762 FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, int32_t charset) { |
| 1796 int32_t charset, | 1763 return InsertText(text, charset, TRUE, TRUE); |
| 1797 const CPVT_SecProps* pSecProps, | |
| 1798 const CPVT_WordProps* pWordProps) { | |
| 1799 return InsertText(text, charset, pSecProps, pWordProps, TRUE, TRUE); | |
| 1800 } | 1764 } |
| 1801 | 1765 |
| 1802 FX_FLOAT CFX_Edit::GetFontSize() const { | 1766 FX_FLOAT CFX_Edit::GetFontSize() const { |
| 1803 return m_pVT->GetFontSize(); | 1767 return m_pVT->GetFontSize(); |
| 1804 } | 1768 } |
| 1805 | 1769 |
| 1806 uint16_t CFX_Edit::GetPasswordChar() const { | 1770 uint16_t CFX_Edit::GetPasswordChar() const { |
| 1807 return m_pVT->GetPasswordChar(); | 1771 return m_pVT->GetPasswordChar(); |
| 1808 } | 1772 } |
| 1809 | 1773 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1857 return m_pVT->SearchWordPlace(EditToVT(point)); | 1821 return m_pVT->SearchWordPlace(EditToVT(point)); |
| 1858 } | 1822 } |
| 1859 | 1823 |
| 1860 return CPVT_WordPlace(); | 1824 return CPVT_WordPlace(); |
| 1861 } | 1825 } |
| 1862 | 1826 |
| 1863 void CFX_Edit::Paint() { | 1827 void CFX_Edit::Paint() { |
| 1864 if (m_pVT->IsValid()) { | 1828 if (m_pVT->IsValid()) { |
| 1865 RearrangeAll(); | 1829 RearrangeAll(); |
| 1866 ScrollToCaret(); | 1830 ScrollToCaret(); |
| 1867 Refresh(RP_NOANALYSE); | 1831 Refresh(); |
| 1868 SetCaretOrigin(); | 1832 SetCaretOrigin(); |
| 1869 SetCaretInfo(); | 1833 SetCaretInfo(); |
| 1870 } | 1834 } |
| 1871 } | 1835 } |
| 1872 | 1836 |
| 1873 void CFX_Edit::RearrangeAll() { | 1837 void CFX_Edit::RearrangeAll() { |
| 1874 if (m_pVT->IsValid()) { | 1838 if (m_pVT->IsValid()) { |
| 1875 m_pVT->UpdateWordPlace(m_wpCaret); | 1839 m_pVT->UpdateWordPlace(m_wpCaret); |
| 1876 m_pVT->RearrangeAll(); | 1840 m_pVT->RearrangeAll(); |
| 1877 m_pVT->UpdateWordPlace(m_wpCaret); | 1841 m_pVT->UpdateWordPlace(m_wpCaret); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1904 } | 1868 } |
| 1905 } | 1869 } |
| 1906 } | 1870 } |
| 1907 | 1871 |
| 1908 void CFX_Edit::SelectAll() { | 1872 void CFX_Edit::SelectAll() { |
| 1909 if (m_pVT->IsValid()) { | 1873 if (m_pVT->IsValid()) { |
| 1910 m_SelState = CFX_Edit_Select(GetWholeWordRange()); | 1874 m_SelState = CFX_Edit_Select(GetWholeWordRange()); |
| 1911 SetCaret(m_SelState.EndPos); | 1875 SetCaret(m_SelState.EndPos); |
| 1912 | 1876 |
| 1913 ScrollToCaret(); | 1877 ScrollToCaret(); |
| 1914 CPVT_WordRange wrVisible = GetVisibleWordRange(); | 1878 Refresh(); |
| 1915 Refresh(RP_OPTIONAL, &wrVisible); | |
| 1916 SetCaretInfo(); | 1879 SetCaretInfo(); |
| 1917 } | 1880 } |
| 1918 } | 1881 } |
| 1919 | 1882 |
| 1920 void CFX_Edit::SelectNone() { | 1883 void CFX_Edit::SelectNone() { |
| 1921 if (m_pVT->IsValid()) { | 1884 if (m_pVT->IsValid()) { |
| 1922 if (m_SelState.IsExist()) { | 1885 if (m_SelState.IsExist()) { |
| 1923 CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange(); | |
| 1924 m_SelState.Default(); | 1886 m_SelState.Default(); |
| 1925 Refresh(RP_OPTIONAL, &wrTemp); | 1887 Refresh(); |
| 1926 } | 1888 } |
| 1927 } | 1889 } |
| 1928 } | 1890 } |
| 1929 | 1891 |
| 1930 FX_BOOL CFX_Edit::IsSelected() const { | 1892 FX_BOOL CFX_Edit::IsSelected() const { |
| 1931 return m_SelState.IsExist(); | 1893 return m_SelState.IsExist(); |
| 1932 } | 1894 } |
| 1933 | 1895 |
| 1934 CFX_FloatPoint CFX_Edit::VTToEdit(const CFX_FloatPoint& point) const { | 1896 CFX_FloatPoint CFX_Edit::VTToEdit(const CFX_FloatPoint& point) const { |
| 1935 CFX_FloatRect rcContent = m_pVT->GetContentRect(); | 1897 CFX_FloatRect rcContent = m_pVT->GetContentRect(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2008 } | 1970 } |
| 2009 } | 1971 } |
| 2010 | 1972 |
| 2011 void CFX_Edit::SetScrollPosX(FX_FLOAT fx) { | 1973 void CFX_Edit::SetScrollPosX(FX_FLOAT fx) { |
| 2012 if (!m_bEnableScroll) | 1974 if (!m_bEnableScroll) |
| 2013 return; | 1975 return; |
| 2014 | 1976 |
| 2015 if (m_pVT->IsValid()) { | 1977 if (m_pVT->IsValid()) { |
| 2016 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.x, fx)) { | 1978 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.x, fx)) { |
| 2017 m_ptScrollPos.x = fx; | 1979 m_ptScrollPos.x = fx; |
| 2018 Refresh(RP_NOANALYSE); | 1980 Refresh(); |
| 2019 } | 1981 } |
| 2020 } | 1982 } |
| 2021 } | 1983 } |
| 2022 | 1984 |
| 2023 void CFX_Edit::SetScrollPosY(FX_FLOAT fy) { | 1985 void CFX_Edit::SetScrollPosY(FX_FLOAT fy) { |
| 2024 if (!m_bEnableScroll) | 1986 if (!m_bEnableScroll) |
| 2025 return; | 1987 return; |
| 2026 | 1988 |
| 2027 if (m_pVT->IsValid()) { | 1989 if (m_pVT->IsValid()) { |
| 2028 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y, fy)) { | 1990 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y, fy)) { |
| 2029 m_ptScrollPos.y = fy; | 1991 m_ptScrollPos.y = fy; |
| 2030 Refresh(RP_NOANALYSE); | 1992 Refresh(); |
| 2031 | 1993 |
| 2032 if (m_pNotify) { | 1994 if (m_pNotify) { |
| 2033 if (!m_bNotifyFlag) { | 1995 if (!m_bNotifyFlag) { |
| 2034 m_bNotifyFlag = TRUE; | 1996 m_bNotifyFlag = TRUE; |
| 2035 m_pNotify->IOnSetScrollPosY(fy); | 1997 m_pNotify->IOnSetScrollPosY(fy); |
| 2036 m_bNotifyFlag = FALSE; | 1998 m_bNotifyFlag = FALSE; |
| 2037 } | 1999 } |
| 2038 } | 2000 } |
| 2039 } | 2001 } |
| 2040 } | 2002 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2127 SetScrollPosY(ptFoot.y + rcPlate.Height()); | 2089 SetScrollPosY(ptFoot.y + rcPlate.Height()); |
| 2128 } | 2090 } |
| 2129 } else if (FX_EDIT_IsFloatBigger(ptHeadEdit.y, rcPlate.top)) { | 2091 } else if (FX_EDIT_IsFloatBigger(ptHeadEdit.y, rcPlate.top)) { |
| 2130 if (FX_EDIT_IsFloatBigger(ptFootEdit.y, rcPlate.bottom)) { | 2092 if (FX_EDIT_IsFloatBigger(ptFootEdit.y, rcPlate.bottom)) { |
| 2131 SetScrollPosY(ptHead.y); | 2093 SetScrollPosY(ptHead.y); |
| 2132 } | 2094 } |
| 2133 } | 2095 } |
| 2134 } | 2096 } |
| 2135 } | 2097 } |
| 2136 | 2098 |
| 2137 void CFX_Edit::Refresh(REFRESH_PLAN_E ePlan, | 2099 void CFX_Edit::Refresh() { |
| 2138 const CPVT_WordRange* pRange1, | |
| 2139 const CPVT_WordRange* pRange2) { | |
| 2140 if (m_bEnableRefresh && m_pVT->IsValid()) { | 2100 if (m_bEnableRefresh && m_pVT->IsValid()) { |
| 2141 m_Refresh.BeginRefresh(); | 2101 m_Refresh.BeginRefresh(); |
| 2142 RefreshPushLineRects(GetVisibleWordRange()); | 2102 RefreshPushLineRects(GetVisibleWordRange()); |
| 2143 | 2103 |
| 2144 m_Refresh.NoAnalyse(); | 2104 m_Refresh.NoAnalyse(); |
| 2145 m_ptRefreshScrollPos = m_ptScrollPos; | 2105 m_ptRefreshScrollPos = m_ptScrollPos; |
| 2146 | 2106 |
| 2147 if (m_pNotify) { | 2107 if (m_pNotify) { |
| 2148 if (!m_bNotifyFlag) { | 2108 if (!m_bNotifyFlag) { |
| 2149 m_bNotifyFlag = TRUE; | 2109 m_bNotifyFlag = TRUE; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2349 void CFX_Edit::OnMouseMove(const CFX_FloatPoint& point, | 2309 void CFX_Edit::OnMouseMove(const CFX_FloatPoint& point, |
| 2350 FX_BOOL bShift, | 2310 FX_BOOL bShift, |
| 2351 FX_BOOL bCtrl) { | 2311 FX_BOOL bCtrl) { |
| 2352 if (m_pVT->IsValid()) { | 2312 if (m_pVT->IsValid()) { |
| 2353 SetCaret(m_pVT->SearchWordPlace(EditToVT(point))); | 2313 SetCaret(m_pVT->SearchWordPlace(EditToVT(point))); |
| 2354 | 2314 |
| 2355 if (m_wpCaret != m_wpOldCaret) { | 2315 if (m_wpCaret != m_wpOldCaret) { |
| 2356 m_SelState.SetEndPos(m_wpCaret); | 2316 m_SelState.SetEndPos(m_wpCaret); |
| 2357 | 2317 |
| 2358 ScrollToCaret(); | 2318 ScrollToCaret(); |
| 2359 CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); | 2319 Refresh(); |
| 2360 Refresh(RP_OPTIONAL, &wr); | |
| 2361 SetCaretOrigin(); | 2320 SetCaretOrigin(); |
| 2362 SetCaretInfo(); | 2321 SetCaretInfo(); |
| 2363 } | 2322 } |
| 2364 } | 2323 } |
| 2365 } | 2324 } |
| 2366 | 2325 |
| 2367 void CFX_Edit::OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl) { | 2326 void CFX_Edit::OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl) { |
| 2368 if (m_pVT->IsValid()) { | 2327 if (m_pVT->IsValid()) { |
| 2369 SetCaret(m_pVT->GetUpWordPlace(m_wpCaret, m_ptCaret)); | 2328 SetCaret(m_pVT->GetUpWordPlace(m_wpCaret, m_ptCaret)); |
| 2370 | 2329 |
| 2371 if (bShift) { | 2330 if (bShift) { |
| 2372 if (m_SelState.IsExist()) | 2331 if (m_SelState.IsExist()) |
| 2373 m_SelState.SetEndPos(m_wpCaret); | 2332 m_SelState.SetEndPos(m_wpCaret); |
| 2374 else | 2333 else |
| 2375 m_SelState.Set(m_wpOldCaret, m_wpCaret); | 2334 m_SelState.Set(m_wpOldCaret, m_wpCaret); |
| 2376 | 2335 |
| 2377 if (m_wpOldCaret != m_wpCaret) { | 2336 if (m_wpOldCaret != m_wpCaret) { |
| 2378 ScrollToCaret(); | 2337 ScrollToCaret(); |
| 2379 CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); | 2338 Refresh(); |
| 2380 Refresh(RP_OPTIONAL, &wr); | |
| 2381 SetCaretInfo(); | 2339 SetCaretInfo(); |
| 2382 } | 2340 } |
| 2383 } else { | 2341 } else { |
| 2384 SelectNone(); | 2342 SelectNone(); |
| 2385 | 2343 |
| 2386 ScrollToCaret(); | 2344 ScrollToCaret(); |
| 2387 SetCaretInfo(); | 2345 SetCaretInfo(); |
| 2388 } | 2346 } |
| 2389 } | 2347 } |
| 2390 } | 2348 } |
| 2391 | 2349 |
| 2392 void CFX_Edit::OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl) { | 2350 void CFX_Edit::OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl) { |
| 2393 if (m_pVT->IsValid()) { | 2351 if (m_pVT->IsValid()) { |
| 2394 SetCaret(m_pVT->GetDownWordPlace(m_wpCaret, m_ptCaret)); | 2352 SetCaret(m_pVT->GetDownWordPlace(m_wpCaret, m_ptCaret)); |
| 2395 | 2353 |
| 2396 if (bShift) { | 2354 if (bShift) { |
| 2397 if (m_SelState.IsExist()) | 2355 if (m_SelState.IsExist()) |
| 2398 m_SelState.SetEndPos(m_wpCaret); | 2356 m_SelState.SetEndPos(m_wpCaret); |
| 2399 else | 2357 else |
| 2400 m_SelState.Set(m_wpOldCaret, m_wpCaret); | 2358 m_SelState.Set(m_wpOldCaret, m_wpCaret); |
| 2401 | 2359 |
| 2402 if (m_wpOldCaret != m_wpCaret) { | 2360 if (m_wpOldCaret != m_wpCaret) { |
| 2403 ScrollToCaret(); | 2361 ScrollToCaret(); |
| 2404 CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); | 2362 Refresh(); |
| 2405 Refresh(RP_OPTIONAL, &wr); | |
| 2406 SetCaretInfo(); | 2363 SetCaretInfo(); |
| 2407 } | 2364 } |
| 2408 } else { | 2365 } else { |
| 2409 SelectNone(); | 2366 SelectNone(); |
| 2410 | 2367 |
| 2411 ScrollToCaret(); | 2368 ScrollToCaret(); |
| 2412 SetCaretInfo(); | 2369 SetCaretInfo(); |
| 2413 } | 2370 } |
| 2414 } | 2371 } |
| 2415 } | 2372 } |
| 2416 | 2373 |
| 2417 void CFX_Edit::OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl) { | 2374 void CFX_Edit::OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl) { |
| 2418 if (m_pVT->IsValid()) { | 2375 if (m_pVT->IsValid()) { |
| 2419 if (bShift) { | 2376 if (bShift) { |
| 2420 if (m_wpCaret == m_pVT->GetLineBeginPlace(m_wpCaret) && | 2377 if (m_wpCaret == m_pVT->GetLineBeginPlace(m_wpCaret) && |
| 2421 m_wpCaret != m_pVT->GetSectionBeginPlace(m_wpCaret)) | 2378 m_wpCaret != m_pVT->GetSectionBeginPlace(m_wpCaret)) |
| 2422 SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret)); | 2379 SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret)); |
| 2423 | 2380 |
| 2424 SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret)); | 2381 SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret)); |
| 2425 | 2382 |
| 2426 if (m_SelState.IsExist()) | 2383 if (m_SelState.IsExist()) |
| 2427 m_SelState.SetEndPos(m_wpCaret); | 2384 m_SelState.SetEndPos(m_wpCaret); |
| 2428 else | 2385 else |
| 2429 m_SelState.Set(m_wpOldCaret, m_wpCaret); | 2386 m_SelState.Set(m_wpOldCaret, m_wpCaret); |
| 2430 | 2387 |
| 2431 if (m_wpOldCaret != m_wpCaret) { | 2388 if (m_wpOldCaret != m_wpCaret) { |
| 2432 ScrollToCaret(); | 2389 ScrollToCaret(); |
| 2433 CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); | 2390 Refresh(); |
| 2434 Refresh(RP_OPTIONAL, &wr); | |
| 2435 SetCaretInfo(); | 2391 SetCaretInfo(); |
| 2436 } | 2392 } |
| 2437 } else { | 2393 } else { |
| 2438 if (m_SelState.IsExist()) { | 2394 if (m_SelState.IsExist()) { |
| 2439 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) < 0) | 2395 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) < 0) |
| 2440 SetCaret(m_SelState.BeginPos); | 2396 SetCaret(m_SelState.BeginPos); |
| 2441 else | 2397 else |
| 2442 SetCaret(m_SelState.EndPos); | 2398 SetCaret(m_SelState.EndPos); |
| 2443 | 2399 |
| 2444 SelectNone(); | 2400 SelectNone(); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 2468 m_wpCaret != m_pVT->GetSectionEndPlace(m_wpCaret)) | 2424 m_wpCaret != m_pVT->GetSectionEndPlace(m_wpCaret)) |
| 2469 SetCaret(m_pVT->GetNextWordPlace(m_wpCaret)); | 2425 SetCaret(m_pVT->GetNextWordPlace(m_wpCaret)); |
| 2470 | 2426 |
| 2471 if (m_SelState.IsExist()) | 2427 if (m_SelState.IsExist()) |
| 2472 m_SelState.SetEndPos(m_wpCaret); | 2428 m_SelState.SetEndPos(m_wpCaret); |
| 2473 else | 2429 else |
| 2474 m_SelState.Set(m_wpOldCaret, m_wpCaret); | 2430 m_SelState.Set(m_wpOldCaret, m_wpCaret); |
| 2475 | 2431 |
| 2476 if (m_wpOldCaret != m_wpCaret) { | 2432 if (m_wpOldCaret != m_wpCaret) { |
| 2477 ScrollToCaret(); | 2433 ScrollToCaret(); |
| 2478 CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); | 2434 Refresh(); |
| 2479 Refresh(RP_OPTIONAL, &wr); | |
| 2480 SetCaretInfo(); | 2435 SetCaretInfo(); |
| 2481 } | 2436 } |
| 2482 } else { | 2437 } else { |
| 2483 if (m_SelState.IsExist()) { | 2438 if (m_SelState.IsExist()) { |
| 2484 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) > 0) | 2439 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) > 0) |
| 2485 SetCaret(m_SelState.BeginPos); | 2440 SetCaret(m_SelState.BeginPos); |
| 2486 else | 2441 else |
| 2487 SetCaret(m_SelState.EndPos); | 2442 SetCaret(m_SelState.EndPos); |
| 2488 | 2443 |
| 2489 SelectNone(); | 2444 SelectNone(); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 2511 SetCaret(m_pVT->GetBeginWordPlace()); | 2466 SetCaret(m_pVT->GetBeginWordPlace()); |
| 2512 else | 2467 else |
| 2513 SetCaret(m_pVT->GetLineBeginPlace(m_wpCaret)); | 2468 SetCaret(m_pVT->GetLineBeginPlace(m_wpCaret)); |
| 2514 | 2469 |
| 2515 if (m_SelState.IsExist()) | 2470 if (m_SelState.IsExist()) |
| 2516 m_SelState.SetEndPos(m_wpCaret); | 2471 m_SelState.SetEndPos(m_wpCaret); |
| 2517 else | 2472 else |
| 2518 m_SelState.Set(m_wpOldCaret, m_wpCaret); | 2473 m_SelState.Set(m_wpOldCaret, m_wpCaret); |
| 2519 | 2474 |
| 2520 ScrollToCaret(); | 2475 ScrollToCaret(); |
| 2521 CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); | 2476 Refresh(); |
| 2522 Refresh(RP_OPTIONAL, &wr); | |
| 2523 SetCaretInfo(); | 2477 SetCaretInfo(); |
| 2524 } else { | 2478 } else { |
| 2525 if (m_SelState.IsExist()) { | 2479 if (m_SelState.IsExist()) { |
| 2526 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) < 0) | 2480 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) < 0) |
| 2527 SetCaret(m_SelState.BeginPos); | 2481 SetCaret(m_SelState.BeginPos); |
| 2528 else | 2482 else |
| 2529 SetCaret(m_SelState.EndPos); | 2483 SetCaret(m_SelState.EndPos); |
| 2530 | 2484 |
| 2531 SelectNone(); | 2485 SelectNone(); |
| 2532 ScrollToCaret(); | 2486 ScrollToCaret(); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 2552 SetCaret(m_pVT->GetEndWordPlace()); | 2506 SetCaret(m_pVT->GetEndWordPlace()); |
| 2553 else | 2507 else |
| 2554 SetCaret(m_pVT->GetLineEndPlace(m_wpCaret)); | 2508 SetCaret(m_pVT->GetLineEndPlace(m_wpCaret)); |
| 2555 | 2509 |
| 2556 if (m_SelState.IsExist()) | 2510 if (m_SelState.IsExist()) |
| 2557 m_SelState.SetEndPos(m_wpCaret); | 2511 m_SelState.SetEndPos(m_wpCaret); |
| 2558 else | 2512 else |
| 2559 m_SelState.Set(m_wpOldCaret, m_wpCaret); | 2513 m_SelState.Set(m_wpOldCaret, m_wpCaret); |
| 2560 | 2514 |
| 2561 ScrollToCaret(); | 2515 ScrollToCaret(); |
| 2562 CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); | 2516 Refresh(); |
| 2563 Refresh(RP_OPTIONAL, &wr); | |
| 2564 SetCaretInfo(); | 2517 SetCaretInfo(); |
| 2565 } else { | 2518 } else { |
| 2566 if (m_SelState.IsExist()) { | 2519 if (m_SelState.IsExist()) { |
| 2567 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) > 0) | 2520 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) > 0) |
| 2568 SetCaret(m_SelState.BeginPos); | 2521 SetCaret(m_SelState.BeginPos); |
| 2569 else | 2522 else |
| 2570 SetCaret(m_SelState.EndPos); | 2523 SetCaret(m_SelState.EndPos); |
| 2571 | 2524 |
| 2572 SelectNone(); | 2525 SelectNone(); |
| 2573 ScrollToCaret(); | 2526 ScrollToCaret(); |
| 2574 SetCaretInfo(); | 2527 SetCaretInfo(); |
| 2575 } else { | 2528 } else { |
| 2576 if (bCtrl) | 2529 if (bCtrl) |
| 2577 SetCaret(m_pVT->GetEndWordPlace()); | 2530 SetCaret(m_pVT->GetEndWordPlace()); |
| 2578 else | 2531 else |
| 2579 SetCaret(m_pVT->GetLineEndPlace(m_wpCaret)); | 2532 SetCaret(m_pVT->GetLineEndPlace(m_wpCaret)); |
| 2580 | 2533 |
| 2581 ScrollToCaret(); | 2534 ScrollToCaret(); |
| 2582 SetCaretOrigin(); | 2535 SetCaretOrigin(); |
| 2583 SetCaretInfo(); | 2536 SetCaretInfo(); |
| 2584 } | 2537 } |
| 2585 } | 2538 } |
| 2586 } | 2539 } |
| 2587 } | 2540 } |
| 2588 | 2541 |
| 2589 void CFX_Edit::SetText(const FX_WCHAR* text, | |
| 2590 int32_t charset, | |
| 2591 const CPVT_SecProps* pSecProps, | |
| 2592 const CPVT_WordProps* pWordProps, | |
| 2593 FX_BOOL bAddUndo, | |
| 2594 FX_BOOL bPaint) { | |
| 2595 Empty(); | |
| 2596 DoInsertText(CPVT_WordPlace(0, 0, -1), text, charset, pSecProps, pWordProps); | |
| 2597 if (bPaint) | |
| 2598 Paint(); | |
| 2599 } | |
| 2600 | |
| 2601 FX_BOOL CFX_Edit::InsertWord(uint16_t word, | 2542 FX_BOOL CFX_Edit::InsertWord(uint16_t word, |
| 2602 int32_t charset, | 2543 int32_t charset, |
| 2603 const CPVT_WordProps* pWordProps, | 2544 const CPVT_WordProps* pWordProps, |
| 2604 FX_BOOL bAddUndo, | 2545 FX_BOOL bAddUndo, |
| 2605 FX_BOOL bPaint) { | 2546 FX_BOOL bPaint) { |
| 2606 if (IsTextOverflow()) | 2547 if (IsTextOverflow()) |
| 2607 return FALSE; | 2548 return FALSE; |
| 2608 | 2549 |
| 2609 if (m_pVT->IsValid()) { | 2550 if (m_pVT->IsValid()) { |
| 2610 m_pVT->UpdateWordPlace(m_wpCaret); | 2551 m_pVT->UpdateWordPlace(m_wpCaret); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2646 | 2587 |
| 2647 if (m_wpCaret != m_wpOldCaret) { | 2588 if (m_wpCaret != m_wpOldCaret) { |
| 2648 if (bAddUndo && m_bEnableUndo) { | 2589 if (bAddUndo && m_bEnableUndo) { |
| 2649 AddEditUndoItem(new CFXEU_InsertReturn(this, m_wpOldCaret, m_wpCaret, | 2590 AddEditUndoItem(new CFXEU_InsertReturn(this, m_wpOldCaret, m_wpCaret, |
| 2650 pSecProps, pWordProps)); | 2591 pSecProps, pWordProps)); |
| 2651 } | 2592 } |
| 2652 | 2593 |
| 2653 if (bPaint) { | 2594 if (bPaint) { |
| 2654 RearrangePart(CPVT_WordRange(m_wpOldCaret, m_wpCaret)); | 2595 RearrangePart(CPVT_WordRange(m_wpOldCaret, m_wpCaret)); |
| 2655 ScrollToCaret(); | 2596 ScrollToCaret(); |
| 2656 CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos); | 2597 Refresh(); |
| 2657 Refresh(RP_ANALYSE, &wr); | |
| 2658 SetCaretOrigin(); | 2598 SetCaretOrigin(); |
| 2659 SetCaretInfo(); | 2599 SetCaretInfo(); |
| 2660 } | 2600 } |
| 2661 | 2601 |
| 2662 if (m_bOprNotify && m_pOprNotify) | 2602 if (m_bOprNotify && m_pOprNotify) |
| 2663 m_pOprNotify->OnInsertReturn(m_wpCaret, m_wpOldCaret); | 2603 m_pOprNotify->OnInsertReturn(m_wpCaret, m_wpOldCaret); |
| 2664 | 2604 |
| 2665 return TRUE; | 2605 return TRUE; |
| 2666 } | 2606 } |
| 2667 } | 2607 } |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 2696 section.SecProps, section.WordProps)); | 2636 section.SecProps, section.WordProps)); |
| 2697 else | 2637 else |
| 2698 AddEditUndoItem(new CFXEU_Backspace( | 2638 AddEditUndoItem(new CFXEU_Backspace( |
| 2699 this, m_wpOldCaret, m_wpCaret, word.Word, word.nCharset, | 2639 this, m_wpOldCaret, m_wpCaret, word.Word, word.nCharset, |
| 2700 section.SecProps, word.WordProps)); | 2640 section.SecProps, word.WordProps)); |
| 2701 } | 2641 } |
| 2702 | 2642 |
| 2703 if (bPaint) { | 2643 if (bPaint) { |
| 2704 RearrangePart(CPVT_WordRange(m_wpCaret, m_wpOldCaret)); | 2644 RearrangePart(CPVT_WordRange(m_wpCaret, m_wpOldCaret)); |
| 2705 ScrollToCaret(); | 2645 ScrollToCaret(); |
| 2706 | 2646 Refresh(); |
| 2707 CPVT_WordRange wr; | |
| 2708 if (m_wpCaret.SecCmp(m_wpOldCaret) != 0) | |
| 2709 wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpCaret), | |
| 2710 GetVisibleWordRange().EndPos); | |
| 2711 else if (m_wpCaret.LineCmp(m_wpOldCaret) != 0) | |
| 2712 wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(m_wpCaret), | |
| 2713 m_pVT->GetSectionEndPlace(m_wpCaret)); | |
| 2714 else | |
| 2715 wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpCaret), | |
| 2716 m_pVT->GetSectionEndPlace(m_wpCaret)); | |
| 2717 | |
| 2718 Refresh(RP_ANALYSE, &wr); | |
| 2719 | |
| 2720 SetCaretOrigin(); | 2647 SetCaretOrigin(); |
| 2721 SetCaretInfo(); | 2648 SetCaretInfo(); |
| 2722 } | 2649 } |
| 2723 | 2650 |
| 2724 if (m_bOprNotify && m_pOprNotify) | 2651 if (m_bOprNotify && m_pOprNotify) |
| 2725 m_pOprNotify->OnBackSpace(m_wpCaret, m_wpOldCaret); | 2652 m_pOprNotify->OnBackSpace(m_wpCaret, m_wpOldCaret); |
| 2726 | 2653 |
| 2727 return TRUE; | 2654 return TRUE; |
| 2728 } | 2655 } |
| 2729 } | 2656 } |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 2759 section.SecProps, section.WordProps, bSecEnd)); | 2686 section.SecProps, section.WordProps, bSecEnd)); |
| 2760 else | 2687 else |
| 2761 AddEditUndoItem(new CFXEU_Delete( | 2688 AddEditUndoItem(new CFXEU_Delete( |
| 2762 this, m_wpOldCaret, m_wpCaret, word.Word, word.nCharset, | 2689 this, m_wpOldCaret, m_wpCaret, word.Word, word.nCharset, |
| 2763 section.SecProps, word.WordProps, bSecEnd)); | 2690 section.SecProps, word.WordProps, bSecEnd)); |
| 2764 } | 2691 } |
| 2765 | 2692 |
| 2766 if (bPaint) { | 2693 if (bPaint) { |
| 2767 RearrangePart(CPVT_WordRange(m_wpOldCaret, m_wpCaret)); | 2694 RearrangePart(CPVT_WordRange(m_wpOldCaret, m_wpCaret)); |
| 2768 ScrollToCaret(); | 2695 ScrollToCaret(); |
| 2769 | 2696 Refresh(); |
| 2770 CPVT_WordRange wr; | |
| 2771 if (bSecEnd) | |
| 2772 wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpOldCaret), | |
| 2773 GetVisibleWordRange().EndPos); | |
| 2774 else if (m_wpCaret.LineCmp(m_wpOldCaret) != 0) | |
| 2775 wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(m_wpCaret), | |
| 2776 m_pVT->GetSectionEndPlace(m_wpCaret)); | |
| 2777 else | |
| 2778 wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpOldCaret), | |
| 2779 m_pVT->GetSectionEndPlace(m_wpCaret)); | |
| 2780 | |
| 2781 Refresh(RP_ANALYSE, &wr); | |
| 2782 | |
| 2783 SetCaretOrigin(); | 2697 SetCaretOrigin(); |
| 2784 SetCaretInfo(); | 2698 SetCaretInfo(); |
| 2785 } | 2699 } |
| 2786 | 2700 |
| 2787 if (m_bOprNotify && m_pOprNotify) | 2701 if (m_bOprNotify && m_pOprNotify) |
| 2788 m_pOprNotify->OnDelete(m_wpCaret, m_wpOldCaret); | 2702 m_pOprNotify->OnDelete(m_wpCaret, m_wpOldCaret); |
| 2789 | 2703 |
| 2790 return TRUE; | 2704 return TRUE; |
| 2791 } | 2705 } |
| 2792 | 2706 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 2816 if (bAddUndo && m_bEnableUndo) | 2730 if (bAddUndo && m_bEnableUndo) |
| 2817 AddEditUndoItem(new CFXEU_Clear(this, range, GetSelText())); | 2731 AddEditUndoItem(new CFXEU_Clear(this, range, GetSelText())); |
| 2818 | 2732 |
| 2819 SelectNone(); | 2733 SelectNone(); |
| 2820 SetCaret(m_pVT->DeleteWords(range)); | 2734 SetCaret(m_pVT->DeleteWords(range)); |
| 2821 m_SelState.Set(m_wpCaret, m_wpCaret); | 2735 m_SelState.Set(m_wpCaret, m_wpCaret); |
| 2822 | 2736 |
| 2823 if (bPaint) { | 2737 if (bPaint) { |
| 2824 RearrangePart(range); | 2738 RearrangePart(range); |
| 2825 ScrollToCaret(); | 2739 ScrollToCaret(); |
| 2826 | 2740 Refresh(); |
| 2827 CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos); | |
| 2828 Refresh(RP_ANALYSE, &wr); | |
| 2829 | |
| 2830 SetCaretOrigin(); | 2741 SetCaretOrigin(); |
| 2831 SetCaretInfo(); | 2742 SetCaretInfo(); |
| 2832 } | 2743 } |
| 2833 | 2744 |
| 2834 if (m_bOprNotify && m_pOprNotify) | 2745 if (m_bOprNotify && m_pOprNotify) |
| 2835 m_pOprNotify->OnClear(m_wpCaret, m_wpOldCaret); | 2746 m_pOprNotify->OnClear(m_wpCaret, m_wpOldCaret); |
| 2836 | 2747 |
| 2837 return TRUE; | 2748 return TRUE; |
| 2838 } | 2749 } |
| 2839 | 2750 |
| 2840 FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, | 2751 FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, |
| 2841 int32_t charset, | 2752 int32_t charset, |
| 2842 const CPVT_SecProps* pSecProps, | |
| 2843 const CPVT_WordProps* pWordProps, | |
| 2844 FX_BOOL bAddUndo, | 2753 FX_BOOL bAddUndo, |
| 2845 FX_BOOL bPaint) { | 2754 FX_BOOL bPaint) { |
| 2846 if (IsTextOverflow()) | 2755 if (IsTextOverflow()) |
| 2847 return FALSE; | 2756 return FALSE; |
| 2848 | 2757 |
| 2849 m_pVT->UpdateWordPlace(m_wpCaret); | 2758 m_pVT->UpdateWordPlace(m_wpCaret); |
| 2850 SetCaret(DoInsertText(m_wpCaret, text, charset, pSecProps, pWordProps)); | 2759 SetCaret(DoInsertText(m_wpCaret, text, charset)); |
| 2851 m_SelState.Set(m_wpCaret, m_wpCaret); | 2760 m_SelState.Set(m_wpCaret, m_wpCaret); |
| 2852 | 2761 |
| 2853 if (m_wpCaret != m_wpOldCaret) { | 2762 if (m_wpCaret != m_wpOldCaret) { |
| 2854 if (bAddUndo && m_bEnableUndo) { | 2763 if (bAddUndo && m_bEnableUndo) { |
| 2855 AddEditUndoItem(new CFXEU_InsertText(this, m_wpOldCaret, m_wpCaret, text, | 2764 AddEditUndoItem( |
| 2856 charset, pSecProps, pWordProps)); | 2765 new CFXEU_InsertText(this, m_wpOldCaret, m_wpCaret, text, charset)); |
| 2857 } | 2766 } |
| 2858 | 2767 |
| 2859 if (bPaint) | 2768 if (bPaint) |
| 2860 PaintInsertText(m_wpOldCaret, m_wpCaret); | 2769 PaintInsertText(m_wpOldCaret, m_wpCaret); |
| 2861 | 2770 |
| 2862 if (m_bOprNotify && m_pOprNotify) | 2771 if (m_bOprNotify && m_pOprNotify) |
| 2863 m_pOprNotify->OnInsertText(m_wpCaret, m_wpOldCaret); | 2772 m_pOprNotify->OnInsertText(m_wpCaret, m_wpOldCaret); |
| 2864 | 2773 |
| 2865 return TRUE; | 2774 return TRUE; |
| 2866 } | 2775 } |
| 2867 return FALSE; | 2776 return FALSE; |
| 2868 } | 2777 } |
| 2869 | 2778 |
| 2870 void CFX_Edit::PaintInsertText(const CPVT_WordPlace& wpOld, | 2779 void CFX_Edit::PaintInsertText(const CPVT_WordPlace& wpOld, |
| 2871 const CPVT_WordPlace& wpNew) { | 2780 const CPVT_WordPlace& wpNew) { |
| 2872 if (m_pVT->IsValid()) { | 2781 if (m_pVT->IsValid()) { |
| 2873 RearrangePart(CPVT_WordRange(wpOld, wpNew)); | 2782 RearrangePart(CPVT_WordRange(wpOld, wpNew)); |
| 2874 ScrollToCaret(); | 2783 ScrollToCaret(); |
| 2875 | 2784 Refresh(); |
| 2876 CPVT_WordRange wr; | |
| 2877 if (m_wpCaret.LineCmp(wpOld) != 0) | |
| 2878 wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(wpOld), | |
| 2879 m_pVT->GetSectionEndPlace(wpNew)); | |
| 2880 else | |
| 2881 wr = CPVT_WordRange(wpOld, m_pVT->GetSectionEndPlace(wpNew)); | |
| 2882 Refresh(RP_ANALYSE, &wr); | |
| 2883 SetCaretOrigin(); | 2785 SetCaretOrigin(); |
| 2884 SetCaretInfo(); | 2786 SetCaretInfo(); |
| 2885 } | 2787 } |
| 2886 } | 2788 } |
| 2887 | 2789 |
| 2888 FX_BOOL CFX_Edit::Redo() { | 2790 FX_BOOL CFX_Edit::Redo() { |
| 2889 if (m_bEnableUndo) { | 2791 if (m_bEnableUndo) { |
| 2890 if (m_Undo.CanRedo()) { | 2792 if (m_Undo.CanRedo()) { |
| 2891 m_Undo.Redo(); | 2793 m_Undo.Redo(); |
| 2892 return TRUE; | 2794 return TRUE; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3038 CPVT_Line line; | 2940 CPVT_Line line; |
| 3039 pIterator->GetLine(line); | 2941 pIterator->GetLine(line); |
| 3040 | 2942 |
| 3041 pIterator->SetAt(wpOld); | 2943 pIterator->SetAt(wpOld); |
| 3042 | 2944 |
| 3043 return line.ptLine.y + line.fLineDescent; | 2945 return line.ptLine.y + line.fLineDescent; |
| 3044 } | 2946 } |
| 3045 | 2947 |
| 3046 CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place, | 2948 CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place, |
| 3047 const FX_WCHAR* text, | 2949 const FX_WCHAR* text, |
| 3048 int32_t charset, | 2950 int32_t charset) { |
| 3049 const CPVT_SecProps* pSecProps, | |
| 3050 const CPVT_WordProps* pWordProps) { | |
| 3051 CPVT_WordPlace wp = place; | 2951 CPVT_WordPlace wp = place; |
| 3052 | 2952 |
| 3053 if (m_pVT->IsValid()) { | 2953 if (m_pVT->IsValid()) { |
| 3054 CFX_WideString sText = text; | 2954 CFX_WideString sText = text; |
| 3055 | 2955 |
| 3056 for (int32_t i = 0, sz = sText.GetLength(); i < sz; i++) { | 2956 for (int32_t i = 0, sz = sText.GetLength(); i < sz; i++) { |
| 3057 uint16_t word = sText[i]; | 2957 uint16_t word = sText[i]; |
| 3058 switch (word) { | 2958 switch (word) { |
| 3059 case 0x0D: | 2959 case 0x0D: |
| 3060 wp = m_pVT->InsertSection(wp, pSecProps, pWordProps); | 2960 wp = m_pVT->InsertSection(wp, nullptr, nullptr); |
| 3061 if (sText[i + 1] == 0x0A) | 2961 if (sText[i + 1] == 0x0A) |
| 3062 i++; | 2962 i++; |
| 3063 break; | 2963 break; |
| 3064 case 0x0A: | 2964 case 0x0A: |
| 3065 wp = m_pVT->InsertSection(wp, pSecProps, pWordProps); | 2965 wp = m_pVT->InsertSection(wp, nullptr, nullptr); |
| 3066 if (sText[i + 1] == 0x0D) | 2966 if (sText[i + 1] == 0x0D) |
| 3067 i++; | 2967 i++; |
| 3068 break; | 2968 break; |
| 3069 case 0x09: | 2969 case 0x09: |
| 3070 word = 0x20; | 2970 word = 0x20; |
| 3071 default: | 2971 default: |
| 3072 wp = m_pVT->InsertWord(wp, word, GetCharSetFromUnicode(word, charset), | 2972 wp = m_pVT->InsertWord(wp, word, GetCharSetFromUnicode(word, charset), |
| 3073 pWordProps); | 2973 nullptr); |
| 3074 break; | 2974 break; |
| 3075 } | 2975 } |
| 3076 } | 2976 } |
| 3077 } | 2977 } |
| 3078 | 2978 |
| 3079 return wp; | 2979 return wp; |
| 3080 } | 2980 } |
| 3081 | 2981 |
| 3082 int32_t CFX_Edit::GetCharSetFromUnicode(uint16_t word, int32_t nOldCharset) { | 2982 int32_t CFX_Edit::GetCharSetFromUnicode(uint16_t word, int32_t nOldCharset) { |
| 3083 if (IPVT_FontMap* pFontMap = GetFontMap()) | 2983 if (IPVT_FontMap* pFontMap = GetFontMap()) |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3219 int32_t CFX_Edit_RectArray::GetSize() const { | 3119 int32_t CFX_Edit_RectArray::GetSize() const { |
| 3220 return m_Rects.GetSize(); | 3120 return m_Rects.GetSize(); |
| 3221 } | 3121 } |
| 3222 | 3122 |
| 3223 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { | 3123 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { |
| 3224 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) | 3124 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) |
| 3225 return nullptr; | 3125 return nullptr; |
| 3226 | 3126 |
| 3227 return m_Rects.GetAt(nIndex); | 3127 return m_Rects.GetAt(nIndex); |
| 3228 } | 3128 } |
| OLD | NEW |