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