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

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

Issue 2570033003: Remove unused CFWL_Edit flags. (Closed)
Patch Set: Rebase to master 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/fwl_widgetdef.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/cfwl_edit.h" 7 #include "xfa/fwl/cfwl_edit.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 int32_t iError = 366 int32_t iError =
367 m_EdtEngine.Insert(nCaret, wsPaste.c_str(), wsPaste.GetLength()); 367 m_EdtEngine.Insert(nCaret, wsPaste.c_str(), wsPaste.GetLength());
368 if (iError < 0) { 368 if (iError < 0) {
369 ProcessInsertError(iError); 369 ProcessInsertError(iError);
370 return false; 370 return false;
371 } 371 }
372 return true; 372 return true;
373 } 373 }
374 374
375 bool CFWL_Edit::Redo(const IFDE_TxtEdtDoRecord* pRecord) { 375 bool CFWL_Edit::Redo(const IFDE_TxtEdtDoRecord* pRecord) {
376 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo)
377 return true;
378 return m_EdtEngine.Redo(pRecord); 376 return m_EdtEngine.Redo(pRecord);
379 } 377 }
380 378
381 bool CFWL_Edit::Undo(const IFDE_TxtEdtDoRecord* pRecord) { 379 bool CFWL_Edit::Undo(const IFDE_TxtEdtDoRecord* pRecord) {
382 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo)
383 return true;
384 return m_EdtEngine.Undo(pRecord); 380 return m_EdtEngine.Undo(pRecord);
385 } 381 }
386 382
387 bool CFWL_Edit::Undo() { 383 bool CFWL_Edit::Undo() {
388 if (!CanUndo()) 384 if (!CanUndo())
389 return false; 385 return false;
390 return Undo(m_DoRecords[m_iCurRecord--].get()); 386 return Undo(m_DoRecords[m_iCurRecord--].get());
391 } 387 }
392 388
393 bool CFWL_Edit::Redo() { 389 bool CFWL_Edit::Redo() {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 CFX_RectF rtClip = m_rtEngine; 530 CFX_RectF rtClip = m_rtEngine;
535 FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; 531 FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX;
536 FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; 532 FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset;
537 CFX_Matrix mt; 533 CFX_Matrix mt;
538 mt.Set(1, 0, 0, 1, fOffSetX, fOffSetY); 534 mt.Set(1, 0, 0, 1, fOffSetX, fOffSetY);
539 if (pMatrix) { 535 if (pMatrix) {
540 pMatrix->TransformRect(rtClip); 536 pMatrix->TransformRect(rtClip);
541 mt.Concat(*pMatrix); 537 mt.Concat(*pMatrix);
542 } 538 }
543 539
544 bool bShowSel = (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoHideSel) || 540 bool bShowSel = !!(m_pProperties->m_dwStates & FWL_WGTSTATE_Focused);
545 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused);
546 if (bShowSel) { 541 if (bShowSel) {
547 CFWL_Widget* pForm = m_pWidgetMgr->GetSystemFormWidget(this); 542 CFWL_Widget* pForm = m_pWidgetMgr->GetSystemFormWidget(this);
548 if (pForm) { 543 if (pForm) {
549 bShowSel = (pForm->GetStates() & FWL_WGTSTATE_Deactivated) != 544 bShowSel = (pForm->GetStates() & FWL_WGTSTATE_Deactivated) !=
550 FWL_WGTSTATE_Deactivated; 545 FWL_WGTSTATE_Deactivated;
551 } 546 }
552 } 547 }
553 548
554 int32_t nSelCount = m_EdtEngine.CountSelRanges(); 549 int32_t nSelCount = m_EdtEngine.CountSelRanges();
555 if (bShowSel && nSelCount > 0) { 550 if (bShowSel && nSelCount > 0) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 UpdateEditLayout(); 626 UpdateEditLayout();
632 if (m_nLimit > -1) 627 if (m_nLimit > -1)
633 m_EdtEngine.SetLimit(m_nLimit); 628 m_EdtEngine.SetLimit(m_nLimit);
634 } 629 }
635 630
636 void CFWL_Edit::UpdateEditParams() { 631 void CFWL_Edit::UpdateEditParams() {
637 FDE_TXTEDTPARAMS params; 632 FDE_TXTEDTPARAMS params;
638 params.nHorzScale = 100; 633 params.nHorzScale = 100;
639 params.fPlateWidth = m_rtEngine.width; 634 params.fPlateWidth = m_rtEngine.width;
640 params.fPlateHeight = m_rtEngine.height; 635 params.fPlateHeight = m_rtEngine.height;
641 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_RTLLayout)
642 params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_RTL;
643 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VerticalLayout)
644 params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_DocVertical;
645 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VerticalChars)
646 params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_CharVertial;
647 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReverseLine)
648 params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_LineReserve;
649 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ArabicShapes)
650 params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_ArabicShapes;
651 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ExpandTab)
652 params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_ExpandTab;
653 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) 636 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText)
654 params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_CombText; 637 params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_CombText;
655 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_LastLineHeight) 638 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_LastLineHeight)
656 params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_LastLineHeight; 639 params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_LastLineHeight;
657 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Validate) 640 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Validate)
658 params.dwMode |= FDE_TEXTEDITMODE_Validate; 641 params.dwMode |= FDE_TEXTEDITMODE_Validate;
659 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Password) 642 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Password)
660 params.dwMode |= FDE_TEXTEDITMODE_Password; 643 params.dwMode |= FDE_TEXTEDITMODE_Password;
661 644
662 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignMask) { 645 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignMask) {
(...skipping 10 matching lines...) Expand all
673 break; 656 break;
674 } 657 }
675 default: 658 default:
676 break; 659 break;
677 } 660 }
678 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignModeMask) { 661 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignModeMask) {
679 case FWL_STYLEEXT_EDT_Justified: { 662 case FWL_STYLEEXT_EDT_Justified: {
680 params.dwAlignment |= FDE_TEXTEDITALIGN_Justified; 663 params.dwAlignment |= FDE_TEXTEDITALIGN_Justified;
681 break; 664 break;
682 } 665 }
683 case FWL_STYLEEXT_EDT_Distributed: {
684 params.dwAlignment |= FDE_TEXTEDITALIGN_Distributed;
685 break;
686 }
687 default: { 666 default: {
688 params.dwAlignment |= FDE_TEXTEDITALIGN_Normal; 667 params.dwAlignment |= FDE_TEXTEDITALIGN_Normal;
689 break; 668 break;
690 } 669 }
691 } 670 }
692 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { 671 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) {
693 params.dwMode |= FDE_TEXTEDITMODE_MultiLines; 672 params.dwMode |= FDE_TEXTEDITMODE_MultiLines;
694 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) == 0 && 673 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) == 0 &&
695 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoHScroll) == 0) { 674 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoHScroll) == 0) {
696 params.dwMode |= 675 params.dwMode |=
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 return true; 1211 return true;
1233 return false; 1212 return false;
1234 } 1213 }
1235 1214
1236 if (wsText.GetInteger() <= m_iMax) 1215 if (wsText.GetInteger() <= m_iMax)
1237 return true; 1216 return true;
1238 return false; 1217 return false;
1239 } 1218 }
1240 1219
1241 void CFWL_Edit::InitCaret() { 1220 void CFWL_Edit::InitCaret() {
1242 if (!m_pCaret) { 1221 if (!m_pCaret)
1243 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) { 1222 return;
1244 m_pCaret = pdfium::MakeUnique<CFWL_Caret>( 1223 m_pCaret.reset();
1245 m_pOwnerApp, pdfium::MakeUnique<CFWL_WidgetProperties>(), this);
1246 m_pCaret->SetParent(this);
1247 m_pCaret->SetStates(m_pProperties->m_dwStates);
1248 }
1249 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret) ==
1250 0) {
1251 m_pCaret.reset();
1252 }
1253 } 1224 }
1254 1225
1255 void CFWL_Edit::ClearRecord() { 1226 void CFWL_Edit::ClearRecord() {
1256 m_iCurRecord = -1; 1227 m_iCurRecord = -1;
1257 m_DoRecords.clear(); 1228 m_DoRecords.clear();
1258 } 1229 }
1259 1230
1260 void CFWL_Edit::ProcessInsertError(int32_t iError) { 1231 void CFWL_Edit::ProcessInsertError(int32_t iError) {
1261 if (iError != -2) 1232 if (iError != -2)
1262 return; 1233 return;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 DeviceToEngine(pt); 1316 DeviceToEngine(pt);
1346 bool bBefore = true; 1317 bool bBefore = true;
1347 int32_t nIndex = pPage->GetCharIndex(pt, bBefore); 1318 int32_t nIndex = pPage->GetCharIndex(pt, bBefore);
1348 if (nIndex < 0) 1319 if (nIndex < 0)
1349 nIndex = 0; 1320 nIndex = 0;
1350 1321
1351 m_EdtEngine.SetCaretPos(nIndex, bBefore); 1322 m_EdtEngine.SetCaretPos(nIndex, bBefore);
1352 } 1323 }
1353 1324
1354 void CFWL_Edit::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { 1325 void CFWL_Edit::OnFocusChanged(CFWL_Message* pMsg, bool bSet) {
1355 uint32_t dwStyleEx = GetStylesEx(); 1326 bool bRepaint = false;
1356 bool bRepaint = !!(dwStyleEx & FWL_STYLEEXT_EDT_InnerCaret);
1357 if (bSet) { 1327 if (bSet) {
1358 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; 1328 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
1359 1329
1360 UpdateVAlignment(); 1330 UpdateVAlignment();
1361 UpdateOffset(); 1331 UpdateOffset();
1362 UpdateCaret(); 1332 UpdateCaret();
1363 } else if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { 1333 } else if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
1364 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; 1334 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
1365 HideCaret(nullptr); 1335 HideCaret(nullptr);
1366 if ((dwStyleEx & FWL_STYLEEXT_EDT_NoHideSel) == 0) { 1336
1367 int32_t nSel = CountSelRanges(); 1337 int32_t nSel = CountSelRanges();
1368 if (nSel > 0) { 1338 if (nSel > 0) {
1369 ClearSelections(); 1339 ClearSelections();
1370 bRepaint = true; 1340 bRepaint = true;
1371 }
1372 m_EdtEngine.SetCaretPos(0, true);
1373 UpdateOffset();
1374 } 1341 }
1342 m_EdtEngine.SetCaretPos(0, true);
1343 UpdateOffset();
1344
1375 ClearRecord(); 1345 ClearRecord();
1376 } 1346 }
1377 1347
1378 LayoutScrollBar(); 1348 LayoutScrollBar();
1379 if (!bRepaint) 1349 if (!bRepaint)
1380 return; 1350 return;
1381 1351
1382 CFX_RectF rtInvalidate; 1352 CFX_RectF rtInvalidate;
1383 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, 1353 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width,
1384 m_pProperties->m_rtWidget.height); 1354 m_pProperties->m_rtWidget.height);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 pScrollBar->SetTrackPos(fPos); 1596 pScrollBar->SetTrackPos(fPos);
1627 UpdateOffset(pScrollBar, fPos - iCurPos); 1597 UpdateOffset(pScrollBar, fPos - iCurPos);
1628 UpdateCaret(); 1598 UpdateCaret();
1629 1599
1630 CFX_RectF rect = GetWidgetRect(); 1600 CFX_RectF rect = GetWidgetRect();
1631 CFX_RectF rtInvalidate; 1601 CFX_RectF rtInvalidate;
1632 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); 1602 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2);
1633 RepaintRect(rtInvalidate); 1603 RepaintRect(rtInvalidate);
1634 return true; 1604 return true;
1635 } 1605 }
OLDNEW
« no previous file with comments | « xfa/fwl/cfwl_edit.h ('k') | xfa/fwl/fwl_widgetdef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698