Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: xfa/fwl/cfwl_edit.cpp

Issue 2559173002: Move xfa/fwl/core to xfa/fwl. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fwl/cfwl_edit.h ('k') | xfa/fwl/cfwl_event.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "xfa/fwl/core/cfwl_edit.h" 7 #include "xfa/fwl/cfwl_edit.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "third_party/base/ptr_util.h" 14 #include "third_party/base/ptr_util.h"
15 #include "third_party/base/stl_util.h" 15 #include "third_party/base/stl_util.h"
16 #include "xfa/fde/cfde_txtedtengine.h" 16 #include "xfa/fde/cfde_txtedtengine.h"
17 #include "xfa/fde/fde_gedevice.h" 17 #include "xfa/fde/fde_gedevice.h"
18 #include "xfa/fde/fde_render.h" 18 #include "xfa/fde/fde_render.h"
19 #include "xfa/fde/ifde_txtedtpage.h" 19 #include "xfa/fde/ifde_txtedtpage.h"
20 #include "xfa/fgas/font/cfgas_gefont.h" 20 #include "xfa/fgas/font/cfgas_gefont.h"
21 #include "xfa/fwl/core/cfwl_app.h" 21 #include "xfa/fwl/cfwl_app.h"
22 #include "xfa/fwl/core/cfwl_caret.h" 22 #include "xfa/fwl/cfwl_caret.h"
23 #include "xfa/fwl/core/cfwl_event.h" 23 #include "xfa/fwl/cfwl_event.h"
24 #include "xfa/fwl/core/cfwl_evtcheckword.h" 24 #include "xfa/fwl/cfwl_eventcheckword.h"
25 #include "xfa/fwl/core/cfwl_evttextchanged.h" 25 #include "xfa/fwl/cfwl_eventtextchanged.h"
26 #include "xfa/fwl/core/cfwl_evtvalidate.h" 26 #include "xfa/fwl/cfwl_eventvalidate.h"
27 #include "xfa/fwl/core/cfwl_msgkey.h" 27 #include "xfa/fwl/cfwl_messagekey.h"
28 #include "xfa/fwl/core/cfwl_msgmouse.h" 28 #include "xfa/fwl/cfwl_messagemouse.h"
29 #include "xfa/fwl/core/cfwl_themebackground.h" 29 #include "xfa/fwl/cfwl_themebackground.h"
30 #include "xfa/fwl/core/cfwl_themepart.h" 30 #include "xfa/fwl/cfwl_themepart.h"
31 #include "xfa/fwl/core/cfwl_widgetmgr.h" 31 #include "xfa/fwl/cfwl_widgetmgr.h"
32 #include "xfa/fwl/core/ifwl_themeprovider.h" 32 #include "xfa/fwl/ifwl_themeprovider.h"
33 #include "xfa/fxfa/xfa_ffdoc.h" 33 #include "xfa/fxfa/xfa_ffdoc.h"
34 #include "xfa/fxfa/xfa_ffwidget.h" 34 #include "xfa/fxfa/xfa_ffwidget.h"
35 #include "xfa/fxgraphics/cfx_path.h" 35 #include "xfa/fxgraphics/cfx_path.h"
36 36
37 namespace { 37 namespace {
38 38
39 const int kEditMargin = 3; 39 const int kEditMargin = 3;
40 40
41 bool FX_EDIT_ISLATINWORD(FX_WCHAR c) { 41 bool FX_EDIT_ISLATINWORD(FX_WCHAR c) {
42 return c == 0x2D || (c <= 0x005A && c >= 0x0041) || 42 return c == 0x2D || (c <= 0x005A && c >= 0x0041) ||
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 187 }
188 } 188 }
189 189
190 void CFWL_Edit::DrawSpellCheck(CFX_Graphics* pGraphics, 190 void CFWL_Edit::DrawSpellCheck(CFX_Graphics* pGraphics,
191 const CFX_Matrix* pMatrix) { 191 const CFX_Matrix* pMatrix) {
192 pGraphics->SaveGraphState(); 192 pGraphics->SaveGraphState();
193 if (pMatrix) 193 if (pMatrix)
194 pGraphics->ConcatMatrix(const_cast<CFX_Matrix*>(pMatrix)); 194 pGraphics->ConcatMatrix(const_cast<CFX_Matrix*>(pMatrix));
195 195
196 CFX_Color crLine(0xFFFF0000); 196 CFX_Color crLine(0xFFFF0000);
197 CFWL_EvtCheckWord checkWordEvent(this); 197 CFWL_EventCheckWord checkWordEvent(this);
198 198
199 CFX_ByteString sLatinWord; 199 CFX_ByteString sLatinWord;
200 CFX_Path pathSpell; 200 CFX_Path pathSpell;
201 pathSpell.Create(); 201 pathSpell.Create();
202 202
203 int32_t nStart = 0; 203 int32_t nStart = 0;
204 FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; 204 FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX;
205 FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; 205 FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset;
206 206
207 CFX_WideString wsSpell = GetText(); 207 CFX_WideString wsSpell = GetText();
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 } 433 }
434 } 434 }
435 435
436 void CFWL_Edit::OnTextChanged(const FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { 436 void CFWL_Edit::OnTextChanged(const FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) {
437 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask) 437 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask)
438 UpdateVAlignment(); 438 UpdateVAlignment();
439 439
440 CFX_RectF rtTemp; 440 CFX_RectF rtTemp;
441 GetClientRect(rtTemp); 441 GetClientRect(rtTemp);
442 442
443 CFWL_EvtTextChanged event(this); 443 CFWL_EventTextChanged event(this);
444 event.wsPrevText = ChangeInfo.wsPrevText; 444 event.wsPrevText = ChangeInfo.wsPrevText;
445 DispatchEvent(&event); 445 DispatchEvent(&event);
446 446
447 LayoutScrollBar(); 447 LayoutScrollBar();
448 Repaint(&rtTemp); 448 Repaint(&rtTemp);
449 } 449 }
450 450
451 void CFWL_Edit::OnSelChanged() { 451 void CFWL_Edit::OnSelChanged() {
452 CFX_RectF rtTemp; 452 CFX_RectF rtTemp;
453 GetClientRect(rtTemp); 453 GetClientRect(rtTemp);
(...skipping 20 matching lines...) Expand all
474 474
475 void CFWL_Edit::OnAddDoRecord(std::unique_ptr<IFDE_TxtEdtDoRecord> pRecord) { 475 void CFWL_Edit::OnAddDoRecord(std::unique_ptr<IFDE_TxtEdtDoRecord> pRecord) {
476 AddDoRecord(std::move(pRecord)); 476 AddDoRecord(std::move(pRecord));
477 } 477 }
478 478
479 bool CFWL_Edit::OnValidate(const CFX_WideString& wsText) { 479 bool CFWL_Edit::OnValidate(const CFX_WideString& wsText) {
480 CFWL_Widget* pDst = GetOuter(); 480 CFWL_Widget* pDst = GetOuter();
481 if (!pDst) 481 if (!pDst)
482 pDst = this; 482 pDst = this;
483 483
484 CFWL_EvtValidate event(this); 484 CFWL_EventValidate event(this);
485 event.wsInsert = wsText; 485 event.wsInsert = wsText;
486 event.bValidate = true; 486 event.bValidate = true;
487 DispatchEvent(&event); 487 DispatchEvent(&event);
488 return event.bValidate; 488 return event.bValidate;
489 } 489 }
490 490
491 void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { 491 void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) {
492 m_fScrollOffsetY = fScrollOffset; 492 m_fScrollOffsetY = fScrollOffset;
493 } 493 }
494 494
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 return; 1279 return;
1280 1280
1281 switch (pMessage->GetType()) { 1281 switch (pMessage->GetType()) {
1282 case CFWL_Message::Type::SetFocus: 1282 case CFWL_Message::Type::SetFocus:
1283 OnFocusChanged(pMessage, true); 1283 OnFocusChanged(pMessage, true);
1284 break; 1284 break;
1285 case CFWL_Message::Type::KillFocus: 1285 case CFWL_Message::Type::KillFocus:
1286 OnFocusChanged(pMessage, false); 1286 OnFocusChanged(pMessage, false);
1287 break; 1287 break;
1288 case CFWL_Message::Type::Mouse: { 1288 case CFWL_Message::Type::Mouse: {
1289 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); 1289 CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage);
1290 switch (pMsg->m_dwCmd) { 1290 switch (pMsg->m_dwCmd) {
1291 case FWL_MouseCommand::LeftButtonDown: 1291 case FWL_MouseCommand::LeftButtonDown:
1292 OnLButtonDown(pMsg); 1292 OnLButtonDown(pMsg);
1293 break; 1293 break;
1294 case FWL_MouseCommand::LeftButtonUp: 1294 case FWL_MouseCommand::LeftButtonUp:
1295 OnLButtonUp(pMsg); 1295 OnLButtonUp(pMsg);
1296 break; 1296 break;
1297 case FWL_MouseCommand::LeftButtonDblClk: 1297 case FWL_MouseCommand::LeftButtonDblClk:
1298 OnButtonDblClk(pMsg); 1298 OnButtonDblClk(pMsg);
1299 break; 1299 break;
1300 case FWL_MouseCommand::Move: 1300 case FWL_MouseCommand::Move:
1301 OnMouseMove(pMsg); 1301 OnMouseMove(pMsg);
1302 break; 1302 break;
1303 case FWL_MouseCommand::RightButtonDown: 1303 case FWL_MouseCommand::RightButtonDown:
1304 DoButtonDown(pMsg); 1304 DoButtonDown(pMsg);
1305 break; 1305 break;
1306 default: 1306 default:
1307 break; 1307 break;
1308 } 1308 }
1309 break; 1309 break;
1310 } 1310 }
1311 case CFWL_Message::Type::Key: { 1311 case CFWL_Message::Type::Key: {
1312 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); 1312 CFWL_MessageKey* pKey = static_cast<CFWL_MessageKey*>(pMessage);
1313 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) 1313 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown)
1314 OnKeyDown(pKey); 1314 OnKeyDown(pKey);
1315 else if (pKey->m_dwCmd == FWL_KeyCommand::Char) 1315 else if (pKey->m_dwCmd == FWL_KeyCommand::Char)
1316 OnChar(pKey); 1316 OnChar(pKey);
1317 break; 1317 break;
1318 } 1318 }
1319 default: 1319 default:
1320 break; 1320 break;
1321 } 1321 }
1322 CFWL_Widget::OnProcessMessage(pMessage); 1322 CFWL_Widget::OnProcessMessage(pMessage);
1323 } 1323 }
1324 1324
1325 void CFWL_Edit::OnProcessEvent(CFWL_Event* pEvent) { 1325 void CFWL_Edit::OnProcessEvent(CFWL_Event* pEvent) {
1326 if (!pEvent) 1326 if (!pEvent)
1327 return; 1327 return;
1328 if (pEvent->GetType() != CFWL_Event::Type::Scroll) 1328 if (pEvent->GetType() != CFWL_Event::Type::Scroll)
1329 return; 1329 return;
1330 1330
1331 CFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; 1331 CFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget;
1332 if ((pSrcTarget == m_pVertScrollBar.get() && m_pVertScrollBar) || 1332 if ((pSrcTarget == m_pVertScrollBar.get() && m_pVertScrollBar) ||
1333 (pSrcTarget == m_pHorzScrollBar.get() && m_pHorzScrollBar)) { 1333 (pSrcTarget == m_pHorzScrollBar.get() && m_pHorzScrollBar)) {
1334 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); 1334 CFWL_EventScroll* pScrollEvent = static_cast<CFWL_EventScroll*>(pEvent);
1335 OnScroll(static_cast<CFWL_ScrollBar*>(pSrcTarget), 1335 OnScroll(static_cast<CFWL_ScrollBar*>(pSrcTarget),
1336 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); 1336 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos);
1337 } 1337 }
1338 } 1338 }
1339 1339
1340 void CFWL_Edit::OnDrawWidget(CFX_Graphics* pGraphics, 1340 void CFWL_Edit::OnDrawWidget(CFX_Graphics* pGraphics,
1341 const CFX_Matrix* pMatrix) { 1341 const CFX_Matrix* pMatrix) {
1342 DrawWidget(pGraphics, pMatrix); 1342 DrawWidget(pGraphics, pMatrix);
1343 } 1343 }
1344 1344
1345 void CFWL_Edit::DoButtonDown(CFWL_MsgMouse* pMsg) { 1345 void CFWL_Edit::DoButtonDown(CFWL_MessageMouse* pMsg) {
1346 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) 1346 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
1347 SetFocus(true); 1347 SetFocus(true);
1348 1348
1349 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); 1349 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0);
1350 if (!pPage) 1350 if (!pPage)
1351 return; 1351 return;
1352 1352
1353 CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); 1353 CFX_PointF pt(pMsg->m_fx, pMsg->m_fy);
1354 DeviceToEngine(pt); 1354 DeviceToEngine(pt);
1355 bool bBefore = true; 1355 bool bBefore = true;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 LayoutScrollBar(); 1387 LayoutScrollBar();
1388 if (!bRepaint) 1388 if (!bRepaint)
1389 return; 1389 return;
1390 1390
1391 CFX_RectF rtInvalidate; 1391 CFX_RectF rtInvalidate;
1392 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, 1392 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width,
1393 m_pProperties->m_rtWidget.height); 1393 m_pProperties->m_rtWidget.height);
1394 Repaint(&rtInvalidate); 1394 Repaint(&rtInvalidate);
1395 } 1395 }
1396 1396
1397 void CFWL_Edit::OnLButtonDown(CFWL_MsgMouse* pMsg) { 1397 void CFWL_Edit::OnLButtonDown(CFWL_MessageMouse* pMsg) {
1398 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) 1398 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
1399 return; 1399 return;
1400 1400
1401 m_bLButtonDown = true; 1401 m_bLButtonDown = true;
1402 SetGrab(true); 1402 SetGrab(true);
1403 DoButtonDown(pMsg); 1403 DoButtonDown(pMsg);
1404 int32_t nIndex = m_EdtEngine.GetCaretPos(); 1404 int32_t nIndex = m_EdtEngine.GetCaretPos();
1405 bool bRepaint = false; 1405 bool bRepaint = false;
1406 if (m_EdtEngine.CountSelRanges() > 0) { 1406 if (m_EdtEngine.CountSelRanges() > 0) {
1407 m_EdtEngine.ClearSelection(); 1407 m_EdtEngine.ClearSelection();
1408 bRepaint = true; 1408 bRepaint = true;
1409 } 1409 }
1410 1410
1411 if ((pMsg->m_dwFlags & FWL_KEYFLAG_Shift) && m_nSelStart != nIndex) { 1411 if ((pMsg->m_dwFlags & FWL_KEYFLAG_Shift) && m_nSelStart != nIndex) {
1412 int32_t iStart = std::min(m_nSelStart, nIndex); 1412 int32_t iStart = std::min(m_nSelStart, nIndex);
1413 int32_t iEnd = std::max(m_nSelStart, nIndex); 1413 int32_t iEnd = std::max(m_nSelStart, nIndex);
1414 m_EdtEngine.AddSelRange(iStart, iEnd - iStart); 1414 m_EdtEngine.AddSelRange(iStart, iEnd - iStart);
1415 bRepaint = true; 1415 bRepaint = true;
1416 } else { 1416 } else {
1417 m_nSelStart = nIndex; 1417 m_nSelStart = nIndex;
1418 } 1418 }
1419 if (bRepaint) 1419 if (bRepaint)
1420 Repaint(&m_rtEngine); 1420 Repaint(&m_rtEngine);
1421 } 1421 }
1422 1422
1423 void CFWL_Edit::OnLButtonUp(CFWL_MsgMouse* pMsg) { 1423 void CFWL_Edit::OnLButtonUp(CFWL_MessageMouse* pMsg) {
1424 m_bLButtonDown = false; 1424 m_bLButtonDown = false;
1425 SetGrab(false); 1425 SetGrab(false);
1426 } 1426 }
1427 1427
1428 void CFWL_Edit::OnButtonDblClk(CFWL_MsgMouse* pMsg) { 1428 void CFWL_Edit::OnButtonDblClk(CFWL_MessageMouse* pMsg) {
1429 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); 1429 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0);
1430 if (!pPage) 1430 if (!pPage)
1431 return; 1431 return;
1432 1432
1433 CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); 1433 CFX_PointF pt(pMsg->m_fx, pMsg->m_fy);
1434 DeviceToEngine(pt); 1434 DeviceToEngine(pt);
1435 int32_t nCount = 0; 1435 int32_t nCount = 0;
1436 int32_t nIndex = pPage->SelectWord(pt, nCount); 1436 int32_t nIndex = pPage->SelectWord(pt, nCount);
1437 if (nIndex < 0) 1437 if (nIndex < 0)
1438 return; 1438 return;
1439 1439
1440 m_EdtEngine.AddSelRange(nIndex, nCount); 1440 m_EdtEngine.AddSelRange(nIndex, nCount);
1441 m_EdtEngine.SetCaretPos(nIndex + nCount - 1, false); 1441 m_EdtEngine.SetCaretPos(nIndex + nCount - 1, false);
1442 Repaint(&m_rtEngine); 1442 Repaint(&m_rtEngine);
1443 } 1443 }
1444 1444
1445 void CFWL_Edit::OnMouseMove(CFWL_MsgMouse* pMsg) { 1445 void CFWL_Edit::OnMouseMove(CFWL_MessageMouse* pMsg) {
1446 if (m_nSelStart == -1 || !m_bLButtonDown) 1446 if (m_nSelStart == -1 || !m_bLButtonDown)
1447 return; 1447 return;
1448 1448
1449 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); 1449 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0);
1450 if (!pPage) 1450 if (!pPage)
1451 return; 1451 return;
1452 1452
1453 CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); 1453 CFX_PointF pt(pMsg->m_fx, pMsg->m_fy);
1454 DeviceToEngine(pt); 1454 DeviceToEngine(pt);
1455 bool bBefore = true; 1455 bool bBefore = true;
1456 int32_t nIndex = pPage->GetCharIndex(pt, bBefore); 1456 int32_t nIndex = pPage->GetCharIndex(pt, bBefore);
1457 m_EdtEngine.SetCaretPos(nIndex, bBefore); 1457 m_EdtEngine.SetCaretPos(nIndex, bBefore);
1458 nIndex = m_EdtEngine.GetCaretPos(); 1458 nIndex = m_EdtEngine.GetCaretPos();
1459 m_EdtEngine.ClearSelection(); 1459 m_EdtEngine.ClearSelection();
1460 1460
1461 if (nIndex == m_nSelStart) 1461 if (nIndex == m_nSelStart)
1462 return; 1462 return;
1463 1463
1464 int32_t nLen = m_EdtEngine.GetTextLength(); 1464 int32_t nLen = m_EdtEngine.GetTextLength();
1465 if (m_nSelStart >= nLen) 1465 if (m_nSelStart >= nLen)
1466 m_nSelStart = nLen; 1466 m_nSelStart = nLen;
1467 1467
1468 m_EdtEngine.AddSelRange(std::min(m_nSelStart, nIndex), 1468 m_EdtEngine.AddSelRange(std::min(m_nSelStart, nIndex),
1469 FXSYS_abs(nIndex - m_nSelStart)); 1469 FXSYS_abs(nIndex - m_nSelStart));
1470 } 1470 }
1471 1471
1472 void CFWL_Edit::OnKeyDown(CFWL_MsgKey* pMsg) { 1472 void CFWL_Edit::OnKeyDown(CFWL_MessageKey* pMsg) {
1473 FDE_TXTEDTMOVECARET MoveCaret = MC_MoveNone; 1473 FDE_TXTEDTMOVECARET MoveCaret = MC_MoveNone;
1474 bool bShift = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Shift); 1474 bool bShift = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Shift);
1475 bool bCtrl = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl); 1475 bool bCtrl = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl);
1476 uint32_t dwKeyCode = pMsg->m_dwKeyCode; 1476 uint32_t dwKeyCode = pMsg->m_dwKeyCode;
1477 switch (dwKeyCode) { 1477 switch (dwKeyCode) {
1478 case FWL_VKEY_Left: { 1478 case FWL_VKEY_Left: {
1479 MoveCaret = MC_Left; 1479 MoveCaret = MC_Left;
1480 break; 1480 break;
1481 } 1481 }
1482 case FWL_VKEY_Right: { 1482 case FWL_VKEY_Right: {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 } 1516 }
1517 case FWL_VKEY_F2: 1517 case FWL_VKEY_F2:
1518 case FWL_VKEY_Tab: 1518 case FWL_VKEY_Tab:
1519 default: 1519 default:
1520 break; 1520 break;
1521 } 1521 }
1522 if (MoveCaret != MC_MoveNone) 1522 if (MoveCaret != MC_MoveNone)
1523 m_EdtEngine.MoveCaretPos(MoveCaret, bShift, bCtrl); 1523 m_EdtEngine.MoveCaretPos(MoveCaret, bShift, bCtrl);
1524 } 1524 }
1525 1525
1526 void CFWL_Edit::OnChar(CFWL_MsgKey* pMsg) { 1526 void CFWL_Edit::OnChar(CFWL_MessageKey* pMsg) {
1527 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || 1527 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) ||
1528 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { 1528 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
1529 return; 1529 return;
1530 } 1530 }
1531 1531
1532 int32_t iError = 0; 1532 int32_t iError = 0;
1533 FX_WCHAR c = static_cast<FX_WCHAR>(pMsg->m_dwKeyCode); 1533 FX_WCHAR c = static_cast<FX_WCHAR>(pMsg->m_dwKeyCode);
1534 int32_t nCaret = m_EdtEngine.GetCaretPos(); 1534 int32_t nCaret = m_EdtEngine.GetCaretPos();
1535 switch (c) { 1535 switch (c) {
1536 case FWL_VKEY_Back: 1536 case FWL_VKEY_Back:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 } 1571 }
1572 iError = m_EdtEngine.Insert(nCaret, &c, 1); 1572 iError = m_EdtEngine.Insert(nCaret, &c, 1);
1573 break; 1573 break;
1574 } 1574 }
1575 } 1575 }
1576 if (iError < 0) 1576 if (iError < 0)
1577 ProcessInsertError(iError); 1577 ProcessInsertError(iError);
1578 } 1578 }
1579 1579
1580 bool CFWL_Edit::OnScroll(CFWL_ScrollBar* pScrollBar, 1580 bool CFWL_Edit::OnScroll(CFWL_ScrollBar* pScrollBar,
1581 CFWL_EvtScroll::Code dwCode, 1581 CFWL_EventScroll::Code dwCode,
1582 FX_FLOAT fPos) { 1582 FX_FLOAT fPos) {
1583 CFX_SizeF fs; 1583 CFX_SizeF fs;
1584 pScrollBar->GetRange(&fs.x, &fs.y); 1584 pScrollBar->GetRange(&fs.x, &fs.y);
1585 FX_FLOAT iCurPos = pScrollBar->GetPos(); 1585 FX_FLOAT iCurPos = pScrollBar->GetPos();
1586 FX_FLOAT fStep = pScrollBar->GetStepSize(); 1586 FX_FLOAT fStep = pScrollBar->GetStepSize();
1587 switch (dwCode) { 1587 switch (dwCode) {
1588 case CFWL_EvtScroll::Code::Min: { 1588 case CFWL_EventScroll::Code::Min: {
1589 fPos = fs.x; 1589 fPos = fs.x;
1590 break; 1590 break;
1591 } 1591 }
1592 case CFWL_EvtScroll::Code::Max: { 1592 case CFWL_EventScroll::Code::Max: {
1593 fPos = fs.y; 1593 fPos = fs.y;
1594 break; 1594 break;
1595 } 1595 }
1596 case CFWL_EvtScroll::Code::StepBackward: { 1596 case CFWL_EventScroll::Code::StepBackward: {
1597 fPos -= fStep; 1597 fPos -= fStep;
1598 if (fPos < fs.x + fStep / 2) { 1598 if (fPos < fs.x + fStep / 2) {
1599 fPos = fs.x; 1599 fPos = fs.x;
1600 } 1600 }
1601 break; 1601 break;
1602 } 1602 }
1603 case CFWL_EvtScroll::Code::StepForward: { 1603 case CFWL_EventScroll::Code::StepForward: {
1604 fPos += fStep; 1604 fPos += fStep;
1605 if (fPos > fs.y - fStep / 2) { 1605 if (fPos > fs.y - fStep / 2) {
1606 fPos = fs.y; 1606 fPos = fs.y;
1607 } 1607 }
1608 break; 1608 break;
1609 } 1609 }
1610 case CFWL_EvtScroll::Code::PageBackward: { 1610 case CFWL_EventScroll::Code::PageBackward: {
1611 fPos -= pScrollBar->GetPageSize(); 1611 fPos -= pScrollBar->GetPageSize();
1612 if (fPos < fs.x) { 1612 if (fPos < fs.x) {
1613 fPos = fs.x; 1613 fPos = fs.x;
1614 } 1614 }
1615 break; 1615 break;
1616 } 1616 }
1617 case CFWL_EvtScroll::Code::PageForward: { 1617 case CFWL_EventScroll::Code::PageForward: {
1618 fPos += pScrollBar->GetPageSize(); 1618 fPos += pScrollBar->GetPageSize();
1619 if (fPos > fs.y) { 1619 if (fPos > fs.y) {
1620 fPos = fs.y; 1620 fPos = fs.y;
1621 } 1621 }
1622 break; 1622 break;
1623 } 1623 }
1624 case CFWL_EvtScroll::Code::Pos: 1624 case CFWL_EventScroll::Code::Pos:
1625 case CFWL_EvtScroll::Code::TrackPos: 1625 case CFWL_EventScroll::Code::TrackPos:
1626 case CFWL_EvtScroll::Code::None: 1626 case CFWL_EventScroll::Code::None:
1627 break; 1627 break;
1628 case CFWL_EvtScroll::Code::EndScroll: 1628 case CFWL_EventScroll::Code::EndScroll:
1629 return false; 1629 return false;
1630 } 1630 }
1631 if (iCurPos == fPos) 1631 if (iCurPos == fPos)
1632 return true; 1632 return true;
1633 1633
1634 pScrollBar->SetPos(fPos); 1634 pScrollBar->SetPos(fPos);
1635 pScrollBar->SetTrackPos(fPos); 1635 pScrollBar->SetTrackPos(fPos);
1636 UpdateOffset(pScrollBar, fPos - iCurPos); 1636 UpdateOffset(pScrollBar, fPos - iCurPos);
1637 UpdateCaret(); 1637 UpdateCaret();
1638 1638
1639 CFX_RectF rect = GetWidgetRect(); 1639 CFX_RectF rect = GetWidgetRect();
1640 CFX_RectF rtInvalidate; 1640 CFX_RectF rtInvalidate;
1641 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); 1641 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2);
1642 Repaint(&rtInvalidate); 1642 Repaint(&rtInvalidate);
1643 return true; 1643 return true;
1644 } 1644 }
OLDNEW
« no previous file with comments | « xfa/fwl/cfwl_edit.h ('k') | xfa/fwl/cfwl_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698