John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
dan sinclair | 89e904b | 2016-03-23 19:29:15 -0400 | [diff] [blame] | 7 | #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 8 | |
dsinclair | 1727aee | 2016-09-29 13:12:56 -0700 | [diff] [blame] | 9 | #include "core/fpdfdoc/cpvt_section.h" |
| 10 | #include "core/fpdfdoc/cpvt_word.h" |
dsinclair | 74a34fc | 2016-09-29 16:41:42 -0700 | [diff] [blame] | 11 | #include "core/fxge/fx_font.h" |
dsinclair | 0bb385b | 2016-09-29 17:03:59 -0700 | [diff] [blame] | 12 | #include "fpdfsdk/fxedit/fxet_edit.h" |
dan sinclair | 89e904b | 2016-03-23 19:29:15 -0400 | [diff] [blame] | 13 | #include "fpdfsdk/pdfwindow/PWL_Caret.h" |
| 14 | #include "fpdfsdk/pdfwindow/PWL_FontMap.h" |
| 15 | #include "fpdfsdk/pdfwindow/PWL_ScrollBar.h" |
| 16 | #include "fpdfsdk/pdfwindow/PWL_Utils.h" |
| 17 | #include "fpdfsdk/pdfwindow/PWL_Wnd.h" |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 18 | #include "public/fpdf_fwlevent.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 19 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 20 | CPWL_EditCtrl::CPWL_EditCtrl() |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 21 | : m_pEdit(new CFX_Edit), |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 22 | m_pEditCaret(nullptr), |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 23 | m_bMouseDown(false), |
npm | ea3c3be | 2016-09-19 07:24:33 -0700 | [diff] [blame] | 24 | m_nCharSet(FXFONT_DEFAULT_CHARSET), |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 25 | m_nCodePage(0) {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 26 | |
dsinclair | dbc7716 | 2016-07-13 11:34:23 -0700 | [diff] [blame] | 27 | CPWL_EditCtrl::~CPWL_EditCtrl() {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 28 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 29 | void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM& cp) { |
| 30 | cp.eCursorType = FXCT_VBEAM; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 31 | } |
| 32 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 33 | void CPWL_EditCtrl::OnCreated() { |
| 34 | SetFontSize(GetCreationParam().fFontSize); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 35 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 36 | m_pEdit->SetFontMap(GetFontMap()); |
| 37 | m_pEdit->SetNotify(this); |
| 38 | m_pEdit->Initialize(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 39 | } |
| 40 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 41 | bool CPWL_EditCtrl::IsWndHorV() { |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 42 | CFX_Matrix mt = GetWindowMatrix(); |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 43 | CFX_PointF point1(0, 1); |
| 44 | CFX_PointF point2(1, 1); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 45 | |
Dan Sinclair | afb4456 | 2017-02-09 13:07:43 -0500 | [diff] [blame] | 46 | mt.TransformPoint(point1.x, point1.y); |
| 47 | mt.TransformPoint(point2.x, point2.y); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 48 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 49 | return point2.y == point1.y; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 50 | } |
| 51 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 52 | void CPWL_EditCtrl::SetCursor() { |
| 53 | if (IsValid()) { |
dsinclair | b959010 | 2016-04-27 06:38:59 -0700 | [diff] [blame] | 54 | if (CFX_SystemHandler* pSH = GetSystemHandler()) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 55 | if (IsWndHorV()) |
| 56 | pSH->SetCursor(FXCT_VBEAM); |
| 57 | else |
| 58 | pSH->SetCursor(FXCT_HBEAM); |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 59 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 60 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 61 | } |
| 62 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 63 | void CPWL_EditCtrl::RePosChildWnd() { |
| 64 | m_pEdit->SetPlateRect(GetClientRect()); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 65 | } |
| 66 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 67 | void CPWL_EditCtrl::OnNotify(CPWL_Wnd* pWnd, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 68 | uint32_t msg, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 69 | intptr_t wParam, |
| 70 | intptr_t lParam) { |
| 71 | CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 72 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 73 | switch (msg) { |
| 74 | case PNM_SETSCROLLINFO: |
| 75 | switch (wParam) { |
| 76 | case SBT_VSCROLL: |
| 77 | if (CPWL_Wnd* pChild = GetVScrollBar()) { |
| 78 | pChild->OnNotify(pWnd, PNM_SETSCROLLINFO, wParam, lParam); |
| 79 | } |
| 80 | break; |
| 81 | } |
| 82 | break; |
| 83 | case PNM_SETSCROLLPOS: |
| 84 | switch (wParam) { |
| 85 | case SBT_VSCROLL: |
| 86 | if (CPWL_Wnd* pChild = GetVScrollBar()) { |
| 87 | pChild->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam); |
| 88 | } |
| 89 | break; |
| 90 | } |
| 91 | break; |
| 92 | case PNM_SCROLLWINDOW: { |
| 93 | FX_FLOAT fPos = *(FX_FLOAT*)lParam; |
| 94 | switch (wParam) { |
| 95 | case SBT_VSCROLL: |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 96 | m_pEdit->SetScrollPos(CFX_PointF(m_pEdit->GetScrollPos().x, fPos)); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 97 | break; |
| 98 | } |
| 99 | } break; |
| 100 | case PNM_SETCARETINFO: { |
| 101 | if (PWL_CARET_INFO* pCaretInfo = (PWL_CARET_INFO*)wParam) { |
| 102 | SetCaret(pCaretInfo->bVisible, pCaretInfo->ptHead, pCaretInfo->ptFoot); |
| 103 | } |
| 104 | } break; |
| 105 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 108 | void CPWL_EditCtrl::CreateChildWnd(const PWL_CREATEPARAM& cp) { |
| 109 | if (!IsReadOnly()) |
| 110 | CreateEditCaret(cp); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 111 | } |
| 112 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 113 | void CPWL_EditCtrl::CreateEditCaret(const PWL_CREATEPARAM& cp) { |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 114 | if (m_pEditCaret) |
| 115 | return; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 116 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 117 | m_pEditCaret = new CPWL_Caret; |
| 118 | m_pEditCaret->SetInvalidRect(GetClientRect()); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 119 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 120 | PWL_CREATEPARAM ecp = cp; |
| 121 | ecp.pParentWnd = this; |
| 122 | ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP; |
| 123 | ecp.dwBorderWidth = 0; |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 124 | ecp.nBorderStyle = BorderStyle::SOLID; |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 125 | ecp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0); |
| 126 | |
| 127 | m_pEditCaret->Create(ecp); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 128 | } |
| 129 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 130 | void CPWL_EditCtrl::SetFontSize(FX_FLOAT fFontSize) { |
| 131 | m_pEdit->SetFontSize(fFontSize); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 132 | } |
| 133 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 134 | FX_FLOAT CPWL_EditCtrl::GetFontSize() const { |
| 135 | return m_pEdit->GetFontSize(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 136 | } |
| 137 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 138 | bool CPWL_EditCtrl::OnKeyDown(uint16_t nChar, uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 139 | if (m_bMouseDown) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 140 | return true; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 141 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 142 | bool bRet = CPWL_Wnd::OnKeyDown(nChar, nFlag); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 143 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 144 | // FILTER |
| 145 | switch (nChar) { |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 146 | default: |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 147 | return false; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 148 | case FWL_VKEY_Delete: |
| 149 | case FWL_VKEY_Up: |
| 150 | case FWL_VKEY_Down: |
| 151 | case FWL_VKEY_Left: |
| 152 | case FWL_VKEY_Right: |
| 153 | case FWL_VKEY_Home: |
| 154 | case FWL_VKEY_End: |
| 155 | case FWL_VKEY_Insert: |
| 156 | case 'C': |
| 157 | case 'V': |
| 158 | case 'X': |
| 159 | case 'A': |
| 160 | case 'Z': |
| 161 | case 'c': |
| 162 | case 'v': |
| 163 | case 'x': |
| 164 | case 'a': |
| 165 | case 'z': |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 166 | break; |
| 167 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 168 | |
thestig | 594b20b | 2016-05-12 21:56:43 -0700 | [diff] [blame] | 169 | if (nChar == FWL_VKEY_Delete && m_pEdit->IsSelected()) |
| 170 | nChar = FWL_VKEY_Unknown; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 171 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 172 | switch (nChar) { |
| 173 | case FWL_VKEY_Delete: |
| 174 | Delete(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 175 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 176 | case FWL_VKEY_Insert: |
| 177 | if (IsSHIFTpressed(nFlag)) |
| 178 | PasteText(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 179 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 180 | case FWL_VKEY_Up: |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 181 | m_pEdit->OnVK_UP(IsSHIFTpressed(nFlag), false); |
| 182 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 183 | case FWL_VKEY_Down: |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 184 | m_pEdit->OnVK_DOWN(IsSHIFTpressed(nFlag), false); |
| 185 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 186 | case FWL_VKEY_Left: |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 187 | m_pEdit->OnVK_LEFT(IsSHIFTpressed(nFlag), false); |
| 188 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 189 | case FWL_VKEY_Right: |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 190 | m_pEdit->OnVK_RIGHT(IsSHIFTpressed(nFlag), false); |
| 191 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 192 | case FWL_VKEY_Home: |
| 193 | m_pEdit->OnVK_HOME(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 194 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 195 | case FWL_VKEY_End: |
| 196 | m_pEdit->OnVK_END(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 197 | return true; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 198 | case FWL_VKEY_Unknown: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 199 | if (!IsSHIFTpressed(nFlag)) |
| 200 | Clear(); |
| 201 | else |
| 202 | CutText(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 203 | return true; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 204 | default: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 205 | break; |
| 206 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 207 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 208 | return bRet; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 209 | } |
| 210 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 211 | bool CPWL_EditCtrl::OnChar(uint16_t nChar, uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 212 | if (m_bMouseDown) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 213 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 214 | |
| 215 | CPWL_Wnd::OnChar(nChar, nFlag); |
| 216 | |
| 217 | // FILTER |
| 218 | switch (nChar) { |
| 219 | case 0x0A: |
| 220 | case 0x1B: |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 221 | return false; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 222 | default: |
| 223 | break; |
| 224 | } |
| 225 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 226 | bool bCtrl = IsCTRLpressed(nFlag); |
| 227 | bool bAlt = IsALTpressed(nFlag); |
| 228 | bool bShift = IsSHIFTpressed(nFlag); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 229 | |
Tom Sepez | 62a70f9 | 2016-03-21 15:00:20 -0700 | [diff] [blame] | 230 | uint16_t word = nChar; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 231 | |
| 232 | if (bCtrl && !bAlt) { |
| 233 | switch (nChar) { |
| 234 | case 'C' - 'A' + 1: |
| 235 | CopyText(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 236 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 237 | case 'V' - 'A' + 1: |
| 238 | PasteText(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 239 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 240 | case 'X' - 'A' + 1: |
| 241 | CutText(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 242 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 243 | case 'A' - 'A' + 1: |
| 244 | SelectAll(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 245 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 246 | case 'Z' - 'A' + 1: |
| 247 | if (bShift) |
| 248 | Redo(); |
| 249 | else |
| 250 | Undo(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 251 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 252 | default: |
| 253 | if (nChar < 32) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 254 | return false; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 255 | } |
| 256 | } |
| 257 | |
| 258 | if (IsReadOnly()) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 259 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 260 | |
| 261 | if (m_pEdit->IsSelected() && word == FWL_VKEY_Back) |
| 262 | word = FWL_VKEY_Unknown; |
| 263 | |
| 264 | Clear(); |
| 265 | |
| 266 | switch (word) { |
| 267 | case FWL_VKEY_Back: |
| 268 | Backspace(); |
| 269 | break; |
| 270 | case FWL_VKEY_Return: |
| 271 | InsertReturn(); |
| 272 | break; |
| 273 | case FWL_VKEY_Unknown: |
| 274 | break; |
| 275 | default: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 276 | InsertWord(word, GetCharSet()); |
| 277 | break; |
| 278 | } |
| 279 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 280 | return true; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 281 | } |
| 282 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 283 | bool CPWL_EditCtrl::OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 284 | CPWL_Wnd::OnLButtonDown(point, nFlag); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 285 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 286 | if (ClientHitTest(point)) { |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 287 | if (m_bMouseDown) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 288 | InvalidateRect(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 289 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 290 | m_bMouseDown = true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 291 | SetCapture(); |
| 292 | |
| 293 | m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 294 | } |
| 295 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 296 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 297 | } |
| 298 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 299 | bool CPWL_EditCtrl::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 300 | CPWL_Wnd::OnLButtonUp(point, nFlag); |
| 301 | |
| 302 | if (m_bMouseDown) { |
| 303 | // can receive keybord message |
| 304 | if (ClientHitTest(point) && !IsFocused()) |
| 305 | SetFocus(); |
| 306 | |
| 307 | ReleaseCapture(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 308 | m_bMouseDown = false; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 309 | } |
| 310 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 311 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 312 | } |
| 313 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 314 | bool CPWL_EditCtrl::OnMouseMove(const CFX_PointF& point, uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 315 | CPWL_Wnd::OnMouseMove(point, nFlag); |
| 316 | |
| 317 | if (m_bMouseDown) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 318 | m_pEdit->OnMouseMove(point, false, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 319 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 320 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 321 | } |
| 322 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 323 | CFX_FloatRect CPWL_EditCtrl::GetContentRect() const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 324 | return m_pEdit->GetContentRect(); |
| 325 | } |
| 326 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 327 | void CPWL_EditCtrl::SetEditCaret(bool bVisible) { |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 328 | CFX_PointF ptHead; |
| 329 | CFX_PointF ptFoot; |
tsepez | 63f545c | 2016-09-13 16:08:49 -0700 | [diff] [blame] | 330 | if (bVisible) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 331 | GetCaretInfo(ptHead, ptFoot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 332 | |
| 333 | CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace(); |
| 334 | IOnSetCaret(bVisible, ptHead, ptFoot, wpTemp); |
| 335 | } |
| 336 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 337 | void CPWL_EditCtrl::GetCaretInfo(CFX_PointF& ptHead, CFX_PointF& ptFoot) const { |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 338 | CFX_Edit_Iterator* pIterator = m_pEdit->GetIterator(); |
thestig | 821d59e | 2016-05-11 12:59:22 -0700 | [diff] [blame] | 339 | pIterator->SetAt(m_pEdit->GetCaret()); |
| 340 | CPVT_Word word; |
| 341 | CPVT_Line line; |
| 342 | if (pIterator->GetWord(word)) { |
| 343 | ptHead.x = word.ptWord.x + word.fWidth; |
| 344 | ptHead.y = word.ptWord.y + word.fAscent; |
| 345 | ptFoot.x = word.ptWord.x + word.fWidth; |
| 346 | ptFoot.y = word.ptWord.y + word.fDescent; |
| 347 | } else if (pIterator->GetLine(line)) { |
| 348 | ptHead.x = line.ptLine.x; |
| 349 | ptHead.y = line.ptLine.y + line.fLineAscent; |
| 350 | ptFoot.x = line.ptLine.x; |
| 351 | ptFoot.y = line.ptLine.y + line.fLineDescent; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 352 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 353 | } |
| 354 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 355 | void CPWL_EditCtrl::GetCaretPos(int32_t& x, int32_t& y) const { |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 356 | CFX_PointF ptHead; |
| 357 | CFX_PointF ptFoot; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 358 | GetCaretInfo(ptHead, ptFoot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 359 | PWLtoWnd(ptHead, x, y); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 360 | } |
| 361 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 362 | void CPWL_EditCtrl::SetCaret(bool bVisible, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 363 | const CFX_PointF& ptHead, |
| 364 | const CFX_PointF& ptFoot) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 365 | if (m_pEditCaret) { |
| 366 | if (!IsFocused() || m_pEdit->IsSelected()) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 367 | bVisible = false; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 368 | |
| 369 | m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot); |
| 370 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 371 | } |
| 372 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 373 | CFX_WideString CPWL_EditCtrl::GetText() const { |
| 374 | return m_pEdit->GetText(); |
| 375 | } |
| 376 | |
| 377 | void CPWL_EditCtrl::SetSel(int32_t nStartChar, int32_t nEndChar) { |
| 378 | m_pEdit->SetSel(nStartChar, nEndChar); |
| 379 | } |
| 380 | |
| 381 | void CPWL_EditCtrl::GetSel(int32_t& nStartChar, int32_t& nEndChar) const { |
| 382 | m_pEdit->GetSel(nStartChar, nEndChar); |
| 383 | } |
| 384 | |
| 385 | void CPWL_EditCtrl::Clear() { |
| 386 | if (!IsReadOnly()) |
| 387 | m_pEdit->Clear(); |
| 388 | } |
| 389 | |
| 390 | void CPWL_EditCtrl::SelectAll() { |
| 391 | m_pEdit->SelectAll(); |
| 392 | } |
| 393 | |
| 394 | void CPWL_EditCtrl::Paint() { |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 395 | m_pEdit->Paint(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 396 | } |
| 397 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 398 | void CPWL_EditCtrl::EnableRefresh(bool bRefresh) { |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 399 | m_pEdit->EnableRefresh(bRefresh); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | int32_t CPWL_EditCtrl::GetCaret() const { |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 403 | return m_pEdit->GetCaret(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | void CPWL_EditCtrl::SetCaret(int32_t nPos) { |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 407 | m_pEdit->SetCaret(nPos); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | int32_t CPWL_EditCtrl::GetTotalWords() const { |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 411 | return m_pEdit->GetTotalWords(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 412 | } |
| 413 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 414 | void CPWL_EditCtrl::SetScrollPos(const CFX_PointF& point) { |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 415 | m_pEdit->SetScrollPos(point); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 416 | } |
| 417 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 418 | CFX_PointF CPWL_EditCtrl::GetScrollPos() const { |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 419 | return m_pEdit->GetScrollPos(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | CPDF_Font* CPWL_EditCtrl::GetCaretFont() const { |
| 423 | int32_t nFontIndex = 0; |
| 424 | |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 425 | CFX_Edit_Iterator* pIterator = m_pEdit->GetIterator(); |
thestig | 821d59e | 2016-05-11 12:59:22 -0700 | [diff] [blame] | 426 | pIterator->SetAt(m_pEdit->GetCaret()); |
| 427 | CPVT_Word word; |
| 428 | CPVT_Section section; |
| 429 | if (pIterator->GetWord(word)) { |
| 430 | nFontIndex = word.nFontIndex; |
| 431 | } else if (HasFlag(PES_RICH)) { |
| 432 | if (pIterator->GetSection(section)) { |
| 433 | nFontIndex = section.WordProps.nFontIndex; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 434 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 435 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 436 | |
dsinclair | c7a7349 | 2016-04-05 12:01:42 -0700 | [diff] [blame] | 437 | if (IPVT_FontMap* pFontMap = GetFontMap()) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 438 | return pFontMap->GetPDFFont(nFontIndex); |
| 439 | |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 440 | return nullptr; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 441 | } |
| 442 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 443 | FX_FLOAT CPWL_EditCtrl::GetCaretFontSize() const { |
| 444 | FX_FLOAT fFontSize = GetFontSize(); |
| 445 | |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 446 | CFX_Edit_Iterator* pIterator = m_pEdit->GetIterator(); |
thestig | 821d59e | 2016-05-11 12:59:22 -0700 | [diff] [blame] | 447 | pIterator->SetAt(m_pEdit->GetCaret()); |
| 448 | CPVT_Word word; |
| 449 | CPVT_Section section; |
| 450 | if (pIterator->GetWord(word)) { |
| 451 | fFontSize = word.fFontSize; |
| 452 | } else if (HasFlag(PES_RICH)) { |
| 453 | if (pIterator->GetSection(section)) { |
| 454 | fFontSize = section.WordProps.fFontSize; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 455 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | return fFontSize; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 459 | } |
| 460 | |
tsepez | 067990c | 2016-09-13 06:46:40 -0700 | [diff] [blame] | 461 | void CPWL_EditCtrl::SetText(const CFX_WideString& wsText) { |
| 462 | m_pEdit->SetText(wsText); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 463 | } |
| 464 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 465 | void CPWL_EditCtrl::CopyText() {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 466 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 467 | void CPWL_EditCtrl::PasteText() {} |
| 468 | |
| 469 | void CPWL_EditCtrl::CutText() {} |
| 470 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 471 | void CPWL_EditCtrl::ShowVScrollBar(bool bShow) {} |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 472 | |
tsepez | 067990c | 2016-09-13 06:46:40 -0700 | [diff] [blame] | 473 | void CPWL_EditCtrl::InsertText(const CFX_WideString& wsText) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 474 | if (!IsReadOnly()) |
npm | ea3c3be | 2016-09-19 07:24:33 -0700 | [diff] [blame] | 475 | m_pEdit->InsertText(wsText, FXFONT_DEFAULT_CHARSET); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 476 | } |
| 477 | |
Tom Sepez | 62a70f9 | 2016-03-21 15:00:20 -0700 | [diff] [blame] | 478 | void CPWL_EditCtrl::InsertWord(uint16_t word, int32_t nCharset) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 479 | if (!IsReadOnly()) |
| 480 | m_pEdit->InsertWord(word, nCharset); |
| 481 | } |
| 482 | |
| 483 | void CPWL_EditCtrl::InsertReturn() { |
| 484 | if (!IsReadOnly()) |
| 485 | m_pEdit->InsertReturn(); |
| 486 | } |
| 487 | |
| 488 | void CPWL_EditCtrl::Delete() { |
| 489 | if (!IsReadOnly()) |
| 490 | m_pEdit->Delete(); |
| 491 | } |
| 492 | |
| 493 | void CPWL_EditCtrl::Backspace() { |
| 494 | if (!IsReadOnly()) |
| 495 | m_pEdit->Backspace(); |
| 496 | } |
| 497 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 498 | bool CPWL_EditCtrl::CanUndo() const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 499 | return !IsReadOnly() && m_pEdit->CanUndo(); |
| 500 | } |
| 501 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 502 | bool CPWL_EditCtrl::CanRedo() const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 503 | return !IsReadOnly() && m_pEdit->CanRedo(); |
| 504 | } |
| 505 | |
| 506 | void CPWL_EditCtrl::Redo() { |
| 507 | if (CanRedo()) |
| 508 | m_pEdit->Redo(); |
| 509 | } |
| 510 | |
| 511 | void CPWL_EditCtrl::Undo() { |
| 512 | if (CanUndo()) |
| 513 | m_pEdit->Undo(); |
| 514 | } |
| 515 | |
| 516 | void CPWL_EditCtrl::IOnSetScrollInfoY(FX_FLOAT fPlateMin, |
| 517 | FX_FLOAT fPlateMax, |
| 518 | FX_FLOAT fContentMin, |
| 519 | FX_FLOAT fContentMax, |
| 520 | FX_FLOAT fSmallStep, |
| 521 | FX_FLOAT fBigStep) { |
| 522 | PWL_SCROLL_INFO Info; |
| 523 | |
| 524 | Info.fPlateWidth = fPlateMax - fPlateMin; |
| 525 | Info.fContentMin = fContentMin; |
| 526 | Info.fContentMax = fContentMax; |
| 527 | Info.fSmallStep = fSmallStep; |
| 528 | Info.fBigStep = fBigStep; |
| 529 | |
| 530 | OnNotify(this, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&Info); |
| 531 | |
| 532 | if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) || |
| 533 | IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) { |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 534 | ShowVScrollBar(false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 535 | } else { |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 536 | ShowVScrollBar(true); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 537 | } |
| 538 | } |
| 539 | |
| 540 | void CPWL_EditCtrl::IOnSetScrollPosY(FX_FLOAT fy) { |
| 541 | OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&fy); |
| 542 | } |
| 543 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 544 | void CPWL_EditCtrl::IOnSetCaret(bool bVisible, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 545 | const CFX_PointF& ptHead, |
| 546 | const CFX_PointF& ptFoot, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 547 | const CPVT_WordPlace& place) { |
| 548 | PWL_CARET_INFO cInfo; |
| 549 | cInfo.bVisible = bVisible; |
| 550 | cInfo.ptHead = ptHead; |
| 551 | cInfo.ptFoot = ptFoot; |
| 552 | |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 553 | OnNotify(this, PNM_SETCARETINFO, (intptr_t)&cInfo, (intptr_t) nullptr); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 554 | } |
| 555 | |
dsinclair | dbc7716 | 2016-07-13 11:34:23 -0700 | [diff] [blame] | 556 | void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps& secProps, |
| 557 | const CPVT_WordProps& wordProps) {} |
| 558 | |
| 559 | void CPWL_EditCtrl::IOnContentChange(const CFX_FloatRect& rcContent) {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 560 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 561 | void CPWL_EditCtrl::IOnInvalidateRect(CFX_FloatRect* pRect) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 562 | InvalidateRect(pRect); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 563 | } |
| 564 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 565 | int32_t CPWL_EditCtrl::GetCharSet() const { |
npm | ea3c3be | 2016-09-19 07:24:33 -0700 | [diff] [blame] | 566 | return m_nCharSet < 0 ? FXFONT_DEFAULT_CHARSET : m_nCharSet; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 567 | } |
| 568 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 569 | void CPWL_EditCtrl::GetTextRange(const CFX_FloatRect& rect, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 570 | int32_t& nStartChar, |
| 571 | int32_t& nEndChar) const { |
| 572 | nStartChar = m_pEdit->WordPlaceToWordIndex( |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 573 | m_pEdit->SearchWordPlace(CFX_PointF(rect.left, rect.top))); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 574 | nEndChar = m_pEdit->WordPlaceToWordIndex( |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 575 | m_pEdit->SearchWordPlace(CFX_PointF(rect.right, rect.bottom))); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 576 | } |
| 577 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 578 | CFX_WideString CPWL_EditCtrl::GetText(int32_t& nStartChar, |
| 579 | int32_t& nEndChar) const { |
| 580 | CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStartChar); |
| 581 | CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar); |
| 582 | return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd)); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 583 | } |
| 584 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 585 | void CPWL_EditCtrl::SetReadyToInput() { |
| 586 | if (m_bMouseDown) { |
| 587 | ReleaseCapture(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 588 | m_bMouseDown = false; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 589 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 590 | } |