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

Side by Side Diff: fpdfsdk/pdfwindow/PWL_EditCtrl.cpp

Issue 2142213002: Remove some IFX_* wrappers. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 5 months 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 | « fpdfsdk/pdfwindow/PWL_EditCtrl.h ('k') | fpdfsdk/pdfwindow/PWL_ListBox.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 "fpdfsdk/pdfwindow/PWL_EditCtrl.h" 7 #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h"
8 8
9 #include "core/fpdfdoc/include/cpvt_section.h" 9 #include "core/fpdfdoc/include/cpvt_section.h"
10 #include "core/fpdfdoc/include/cpvt_word.h" 10 #include "core/fpdfdoc/include/cpvt_word.h"
11 #include "fpdfsdk/fxedit/include/fxet_edit.h"
11 #include "fpdfsdk/pdfwindow/PWL_Caret.h" 12 #include "fpdfsdk/pdfwindow/PWL_Caret.h"
12 #include "fpdfsdk/pdfwindow/PWL_FontMap.h" 13 #include "fpdfsdk/pdfwindow/PWL_FontMap.h"
13 #include "fpdfsdk/pdfwindow/PWL_ScrollBar.h" 14 #include "fpdfsdk/pdfwindow/PWL_ScrollBar.h"
14 #include "fpdfsdk/pdfwindow/PWL_Utils.h" 15 #include "fpdfsdk/pdfwindow/PWL_Utils.h"
15 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" 16 #include "fpdfsdk/pdfwindow/PWL_Wnd.h"
16 #include "public/fpdf_fwlevent.h" 17 #include "public/fpdf_fwlevent.h"
17 18
18 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) 19 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
19 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) 20 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
20 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) 21 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
21 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) 22 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb))
22 23
23 CPWL_EditCtrl::CPWL_EditCtrl() 24 CPWL_EditCtrl::CPWL_EditCtrl()
24 : m_pEdit(IFX_Edit::NewEdit()), 25 : m_pEdit(new CFX_Edit),
25 m_pEditCaret(nullptr), 26 m_pEditCaret(nullptr),
26 m_bMouseDown(FALSE), 27 m_bMouseDown(FALSE),
27 m_pEditNotify(nullptr), 28 m_pEditNotify(nullptr),
28 m_nCharSet(DEFAULT_CHARSET), 29 m_nCharSet(DEFAULT_CHARSET),
29 m_nCodePage(0) {} 30 m_nCodePage(0) {}
30 31
31 CPWL_EditCtrl::~CPWL_EditCtrl() { 32 CPWL_EditCtrl::~CPWL_EditCtrl() {
32 IFX_Edit::DelEdit(m_pEdit);
33 } 33 }
34 34
35 void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM& cp) { 35 void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM& cp) {
36 cp.eCursorType = FXCT_VBEAM; 36 cp.eCursorType = FXCT_VBEAM;
37 } 37 }
38 38
39 void CPWL_EditCtrl::OnCreated() { 39 void CPWL_EditCtrl::OnCreated() {
40 SetFontSize(GetCreationParam().fFontSize); 40 SetFontSize(GetCreationParam().fFontSize);
41 41
42 m_pEdit->SetFontMap(GetFontMap()); 42 m_pEdit->SetFontMap(GetFontMap());
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 if (bVisible) { 340 if (bVisible) {
341 GetCaretInfo(ptHead, ptFoot); 341 GetCaretInfo(ptHead, ptFoot);
342 } 342 }
343 343
344 CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace(); 344 CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace();
345 IOnSetCaret(bVisible, ptHead, ptFoot, wpTemp); 345 IOnSetCaret(bVisible, ptHead, ptFoot, wpTemp);
346 } 346 }
347 347
348 void CPWL_EditCtrl::GetCaretInfo(CFX_FloatPoint& ptHead, 348 void CPWL_EditCtrl::GetCaretInfo(CFX_FloatPoint& ptHead,
349 CFX_FloatPoint& ptFoot) const { 349 CFX_FloatPoint& ptFoot) const {
350 IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator(); 350 CFX_Edit_Iterator* pIterator = m_pEdit->GetIterator();
351 pIterator->SetAt(m_pEdit->GetCaret()); 351 pIterator->SetAt(m_pEdit->GetCaret());
352 CPVT_Word word; 352 CPVT_Word word;
353 CPVT_Line line; 353 CPVT_Line line;
354 if (pIterator->GetWord(word)) { 354 if (pIterator->GetWord(word)) {
355 ptHead.x = word.ptWord.x + word.fWidth; 355 ptHead.x = word.ptWord.x + word.fWidth;
356 ptHead.y = word.ptWord.y + word.fAscent; 356 ptHead.y = word.ptWord.y + word.fAscent;
357 ptFoot.x = word.ptWord.x + word.fWidth; 357 ptFoot.x = word.ptWord.x + word.fWidth;
358 ptFoot.y = word.ptWord.y + word.fDescent; 358 ptFoot.y = word.ptWord.y + word.fDescent;
359 } else if (pIterator->GetLine(line)) { 359 } else if (pIterator->GetLine(line)) {
360 ptHead.x = line.ptLine.x; 360 ptHead.x = line.ptLine.x;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 m_pEdit->SetScrollPos(point); 428 m_pEdit->SetScrollPos(point);
429 } 429 }
430 430
431 CFX_FloatPoint CPWL_EditCtrl::GetScrollPos() const { 431 CFX_FloatPoint CPWL_EditCtrl::GetScrollPos() const {
432 return m_pEdit->GetScrollPos(); 432 return m_pEdit->GetScrollPos();
433 } 433 }
434 434
435 CPDF_Font* CPWL_EditCtrl::GetCaretFont() const { 435 CPDF_Font* CPWL_EditCtrl::GetCaretFont() const {
436 int32_t nFontIndex = 0; 436 int32_t nFontIndex = 0;
437 437
438 IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator(); 438 CFX_Edit_Iterator* pIterator = m_pEdit->GetIterator();
439 pIterator->SetAt(m_pEdit->GetCaret()); 439 pIterator->SetAt(m_pEdit->GetCaret());
440 CPVT_Word word; 440 CPVT_Word word;
441 CPVT_Section section; 441 CPVT_Section section;
442 if (pIterator->GetWord(word)) { 442 if (pIterator->GetWord(word)) {
443 nFontIndex = word.nFontIndex; 443 nFontIndex = word.nFontIndex;
444 } else if (HasFlag(PES_RICH)) { 444 } else if (HasFlag(PES_RICH)) {
445 if (pIterator->GetSection(section)) { 445 if (pIterator->GetSection(section)) {
446 nFontIndex = section.WordProps.nFontIndex; 446 nFontIndex = section.WordProps.nFontIndex;
447 } 447 }
448 } 448 }
449 449
450 if (IPVT_FontMap* pFontMap = GetFontMap()) 450 if (IPVT_FontMap* pFontMap = GetFontMap())
451 return pFontMap->GetPDFFont(nFontIndex); 451 return pFontMap->GetPDFFont(nFontIndex);
452 452
453 return nullptr; 453 return nullptr;
454 } 454 }
455 455
456 FX_FLOAT CPWL_EditCtrl::GetCaretFontSize() const { 456 FX_FLOAT CPWL_EditCtrl::GetCaretFontSize() const {
457 FX_FLOAT fFontSize = GetFontSize(); 457 FX_FLOAT fFontSize = GetFontSize();
458 458
459 IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator(); 459 CFX_Edit_Iterator* pIterator = m_pEdit->GetIterator();
460 pIterator->SetAt(m_pEdit->GetCaret()); 460 pIterator->SetAt(m_pEdit->GetCaret());
461 CPVT_Word word; 461 CPVT_Word word;
462 CPVT_Section section; 462 CPVT_Section section;
463 if (pIterator->GetWord(word)) { 463 if (pIterator->GetWord(word)) {
464 fFontSize = word.fFontSize; 464 fFontSize = word.fFontSize;
465 } else if (HasFlag(PES_RICH)) { 465 } else if (HasFlag(PES_RICH)) {
466 if (pIterator->GetSection(section)) { 466 if (pIterator->GetSection(section)) {
467 fFontSize = section.WordProps.fFontSize; 467 fFontSize = section.WordProps.fFontSize;
468 } 468 }
469 } 469 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar); 597 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar);
598 return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd)); 598 return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd));
599 } 599 }
600 600
601 void CPWL_EditCtrl::SetReadyToInput() { 601 void CPWL_EditCtrl::SetReadyToInput() {
602 if (m_bMouseDown) { 602 if (m_bMouseDown) {
603 ReleaseCapture(); 603 ReleaseCapture();
604 m_bMouseDown = FALSE; 604 m_bMouseDown = FALSE;
605 } 605 }
606 } 606 }
OLDNEW
« no previous file with comments | « fpdfsdk/pdfwindow/PWL_EditCtrl.h ('k') | fpdfsdk/pdfwindow/PWL_ListBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698