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

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

Issue 1743753002: Revert "Replace CPDF_Rect and CPDF_Point with CFX types." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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/src/pdfwindow/PWL_Edit.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Icon.cpp » ('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/include/pdfwindow/PWL_EditCtrl.h" 7 #include "fpdfsdk/include/pdfwindow/PWL_EditCtrl.h"
8 8
9 #include "fpdfsdk/include/pdfwindow/PWL_Caret.h" 9 #include "fpdfsdk/include/pdfwindow/PWL_Caret.h"
10 #include "fpdfsdk/include/pdfwindow/PWL_FontMap.h" 10 #include "fpdfsdk/include/pdfwindow/PWL_FontMap.h"
(...skipping 29 matching lines...) Expand all
40 void CPWL_EditCtrl::OnCreated() { 40 void CPWL_EditCtrl::OnCreated() {
41 SetFontSize(GetCreationParam().fFontSize); 41 SetFontSize(GetCreationParam().fFontSize);
42 42
43 m_pEdit->SetFontMap(GetFontMap()); 43 m_pEdit->SetFontMap(GetFontMap());
44 m_pEdit->SetNotify(this); 44 m_pEdit->SetNotify(this);
45 m_pEdit->Initialize(); 45 m_pEdit->Initialize();
46 } 46 }
47 47
48 FX_BOOL CPWL_EditCtrl::IsWndHorV() { 48 FX_BOOL CPWL_EditCtrl::IsWndHorV() {
49 CFX_Matrix mt = GetWindowMatrix(); 49 CFX_Matrix mt = GetWindowMatrix();
50 CFX_FloatPoint point1(0, 1); 50 CPDF_Point point1(0, 1);
51 CFX_FloatPoint point2(1, 1); 51 CPDF_Point point2(1, 1);
52 52
53 mt.Transform(point1.x, point1.y); 53 mt.Transform(point1.x, point1.y);
54 mt.Transform(point2.x, point2.y); 54 mt.Transform(point2.x, point2.y);
55 55
56 return point2.y == point1.y; 56 return point2.y == point1.y;
57 } 57 }
58 58
59 void CPWL_EditCtrl::SetCursor() { 59 void CPWL_EditCtrl::SetCursor() {
60 if (IsValid()) { 60 if (IsValid()) {
61 if (IFX_SystemHandler* pSH = GetSystemHandler()) { 61 if (IFX_SystemHandler* pSH = GetSystemHandler()) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 if (CPWL_Wnd* pChild = GetVScrollBar()) { 93 if (CPWL_Wnd* pChild = GetVScrollBar()) {
94 pChild->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam); 94 pChild->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam);
95 } 95 }
96 break; 96 break;
97 } 97 }
98 break; 98 break;
99 case PNM_SCROLLWINDOW: { 99 case PNM_SCROLLWINDOW: {
100 FX_FLOAT fPos = *(FX_FLOAT*)lParam; 100 FX_FLOAT fPos = *(FX_FLOAT*)lParam;
101 switch (wParam) { 101 switch (wParam) {
102 case SBT_VSCROLL: 102 case SBT_VSCROLL:
103 m_pEdit->SetScrollPos( 103 m_pEdit->SetScrollPos(CPDF_Point(m_pEdit->GetScrollPos().x, fPos));
104 CFX_FloatPoint(m_pEdit->GetScrollPos().x, fPos));
105 break; 104 break;
106 } 105 }
107 } break; 106 } break;
108 case PNM_SETCARETINFO: { 107 case PNM_SETCARETINFO: {
109 if (PWL_CARET_INFO* pCaretInfo = (PWL_CARET_INFO*)wParam) { 108 if (PWL_CARET_INFO* pCaretInfo = (PWL_CARET_INFO*)wParam) {
110 SetCaret(pCaretInfo->bVisible, pCaretInfo->ptHead, pCaretInfo->ptFoot); 109 SetCaret(pCaretInfo->bVisible, pCaretInfo->ptHead, pCaretInfo->ptFoot);
111 } 110 }
112 } break; 111 } break;
113 } 112 }
114 } 113 }
115 114
116 void CPWL_EditCtrl::CreateChildWnd(const PWL_CREATEPARAM& cp) { 115 void CPWL_EditCtrl::CreateChildWnd(const PWL_CREATEPARAM& cp) {
117 if (!IsReadOnly()) 116 if (!IsReadOnly())
118 CreateEditCaret(cp); 117 CreateEditCaret(cp);
119 } 118 }
120 119
121 void CPWL_EditCtrl::CreateEditCaret(const PWL_CREATEPARAM& cp) { 120 void CPWL_EditCtrl::CreateEditCaret(const PWL_CREATEPARAM& cp) {
122 if (!m_pEditCaret) { 121 if (!m_pEditCaret) {
123 m_pEditCaret = new CPWL_Caret; 122 m_pEditCaret = new CPWL_Caret;
124 m_pEditCaret->SetInvalidRect(GetClientRect()); 123 m_pEditCaret->SetInvalidRect(GetClientRect());
125 124
126 PWL_CREATEPARAM ecp = cp; 125 PWL_CREATEPARAM ecp = cp;
127 ecp.pParentWnd = this; 126 ecp.pParentWnd = this;
128 ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP; 127 ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP;
129 ecp.dwBorderWidth = 0; 128 ecp.dwBorderWidth = 0;
130 ecp.nBorderStyle = PBS_SOLID; 129 ecp.nBorderStyle = PBS_SOLID;
131 ecp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0); 130 ecp.rcRectWnd = CPDF_Rect(0, 0, 0, 0);
132 131
133 m_pEditCaret->Create(ecp); 132 m_pEditCaret->Create(ecp);
134 } 133 }
135 } 134 }
136 135
137 void CPWL_EditCtrl::SetFontSize(FX_FLOAT fFontSize) { 136 void CPWL_EditCtrl::SetFontSize(FX_FLOAT fFontSize) {
138 m_pEdit->SetFontSize(fFontSize); 137 m_pEdit->SetFontSize(fFontSize);
139 } 138 }
140 139
141 FX_FLOAT CPWL_EditCtrl::GetFontSize() const { 140 FX_FLOAT CPWL_EditCtrl::GetFontSize() const {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 default: 283 default:
285 if (IsINSERTpressed(nFlag)) 284 if (IsINSERTpressed(nFlag))
286 Delete(); 285 Delete();
287 InsertWord(word, GetCharSet()); 286 InsertWord(word, GetCharSet());
288 break; 287 break;
289 } 288 }
290 289
291 return TRUE; 290 return TRUE;
292 } 291 }
293 292
294 FX_BOOL CPWL_EditCtrl::OnLButtonDown(const CFX_FloatPoint& point, 293 FX_BOOL CPWL_EditCtrl::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) {
295 FX_DWORD nFlag) {
296 CPWL_Wnd::OnLButtonDown(point, nFlag); 294 CPWL_Wnd::OnLButtonDown(point, nFlag);
297 295
298 if (ClientHitTest(point)) { 296 if (ClientHitTest(point)) {
299 if (m_bMouseDown) 297 if (m_bMouseDown)
300 InvalidateRect(); 298 InvalidateRect();
301 299
302 m_bMouseDown = TRUE; 300 m_bMouseDown = TRUE;
303 SetCapture(); 301 SetCapture();
304 302
305 m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); 303 m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
306 } 304 }
307 305
308 return TRUE; 306 return TRUE;
309 } 307 }
310 308
311 FX_BOOL CPWL_EditCtrl::OnLButtonUp(const CFX_FloatPoint& point, 309 FX_BOOL CPWL_EditCtrl::OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) {
312 FX_DWORD nFlag) {
313 CPWL_Wnd::OnLButtonUp(point, nFlag); 310 CPWL_Wnd::OnLButtonUp(point, nFlag);
314 311
315 if (m_bMouseDown) { 312 if (m_bMouseDown) {
316 // can receive keybord message 313 // can receive keybord message
317 if (ClientHitTest(point) && !IsFocused()) 314 if (ClientHitTest(point) && !IsFocused())
318 SetFocus(); 315 SetFocus();
319 316
320 ReleaseCapture(); 317 ReleaseCapture();
321 m_bMouseDown = FALSE; 318 m_bMouseDown = FALSE;
322 } 319 }
323 320
324 return TRUE; 321 return TRUE;
325 } 322 }
326 323
327 FX_BOOL CPWL_EditCtrl::OnMouseMove(const CFX_FloatPoint& point, 324 FX_BOOL CPWL_EditCtrl::OnMouseMove(const CPDF_Point& point, FX_DWORD nFlag) {
328 FX_DWORD nFlag) {
329 CPWL_Wnd::OnMouseMove(point, nFlag); 325 CPWL_Wnd::OnMouseMove(point, nFlag);
330 326
331 if (m_bMouseDown) 327 if (m_bMouseDown)
332 m_pEdit->OnMouseMove(point, FALSE, FALSE); 328 m_pEdit->OnMouseMove(point, FALSE, FALSE);
333 329
334 return TRUE; 330 return TRUE;
335 } 331 }
336 332
337 CFX_FloatRect CPWL_EditCtrl::GetContentRect() const { 333 CPDF_Rect CPWL_EditCtrl::GetContentRect() const {
338 return m_pEdit->GetContentRect(); 334 return m_pEdit->GetContentRect();
339 } 335 }
340 336
341 void CPWL_EditCtrl::SetEditCaret(FX_BOOL bVisible) { 337 void CPWL_EditCtrl::SetEditCaret(FX_BOOL bVisible) {
342 CFX_FloatPoint ptHead(0, 0), ptFoot(0, 0); 338 CPDF_Point ptHead(0, 0), ptFoot(0, 0);
343 339
344 if (bVisible) { 340 if (bVisible) {
345 GetCaretInfo(ptHead, ptFoot); 341 GetCaretInfo(ptHead, ptFoot);
346 } 342 }
347 343
348 CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace(); 344 CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace();
349 IOnSetCaret(bVisible, ptHead, ptFoot, wpTemp); 345 IOnSetCaret(bVisible, ptHead, ptFoot, wpTemp);
350 } 346 }
351 347
352 void CPWL_EditCtrl::GetCaretInfo(CFX_FloatPoint& ptHead, 348 void CPWL_EditCtrl::GetCaretInfo(CPDF_Point& ptHead, CPDF_Point& ptFoot) const {
353 CFX_FloatPoint& ptFoot) const {
354 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { 349 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) {
355 pIterator->SetAt(m_pEdit->GetCaret()); 350 pIterator->SetAt(m_pEdit->GetCaret());
356 CPVT_Word word; 351 CPVT_Word word;
357 CPVT_Line line; 352 CPVT_Line line;
358 if (pIterator->GetWord(word)) { 353 if (pIterator->GetWord(word)) {
359 ptHead.x = word.ptWord.x + word.fWidth; 354 ptHead.x = word.ptWord.x + word.fWidth;
360 ptHead.y = word.ptWord.y + word.fAscent; 355 ptHead.y = word.ptWord.y + word.fAscent;
361 ptFoot.x = word.ptWord.x + word.fWidth; 356 ptFoot.x = word.ptWord.x + word.fWidth;
362 ptFoot.y = word.ptWord.y + word.fDescent; 357 ptFoot.y = word.ptWord.y + word.fDescent;
363 } else if (pIterator->GetLine(line)) { 358 } else if (pIterator->GetLine(line)) {
364 ptHead.x = line.ptLine.x; 359 ptHead.x = line.ptLine.x;
365 ptHead.y = line.ptLine.y + line.fLineAscent; 360 ptHead.y = line.ptLine.y + line.fLineAscent;
366 ptFoot.x = line.ptLine.x; 361 ptFoot.x = line.ptLine.x;
367 ptFoot.y = line.ptLine.y + line.fLineDescent; 362 ptFoot.y = line.ptLine.y + line.fLineDescent;
368 } 363 }
369 } 364 }
370 } 365 }
371 366
372 void CPWL_EditCtrl::GetCaretPos(int32_t& x, int32_t& y) const { 367 void CPWL_EditCtrl::GetCaretPos(int32_t& x, int32_t& y) const {
373 CFX_FloatPoint ptHead(0, 0), ptFoot(0, 0); 368 CPDF_Point ptHead(0, 0), ptFoot(0, 0);
374 369
375 GetCaretInfo(ptHead, ptFoot); 370 GetCaretInfo(ptHead, ptFoot);
376 371
377 PWLtoWnd(ptHead, x, y); 372 PWLtoWnd(ptHead, x, y);
378 } 373 }
379 374
380 void CPWL_EditCtrl::SetCaret(FX_BOOL bVisible, 375 void CPWL_EditCtrl::SetCaret(FX_BOOL bVisible,
381 const CFX_FloatPoint& ptHead, 376 const CPDF_Point& ptHead,
382 const CFX_FloatPoint& ptFoot) { 377 const CPDF_Point& ptFoot) {
383 if (m_pEditCaret) { 378 if (m_pEditCaret) {
384 if (!IsFocused() || m_pEdit->IsSelected()) 379 if (!IsFocused() || m_pEdit->IsSelected())
385 bVisible = FALSE; 380 bVisible = FALSE;
386 381
387 m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot); 382 m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot);
388 } 383 }
389 } 384 }
390 385
391 CFX_WideString CPWL_EditCtrl::GetText() const { 386 CFX_WideString CPWL_EditCtrl::GetText() const {
392 return m_pEdit->GetText(); 387 return m_pEdit->GetText();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 m_pEdit->SetCaret(nPos); 426 m_pEdit->SetCaret(nPos);
432 } 427 }
433 428
434 int32_t CPWL_EditCtrl::GetTotalWords() const { 429 int32_t CPWL_EditCtrl::GetTotalWords() const {
435 if (m_pEdit) 430 if (m_pEdit)
436 return m_pEdit->GetTotalWords(); 431 return m_pEdit->GetTotalWords();
437 432
438 return 0; 433 return 0;
439 } 434 }
440 435
441 void CPWL_EditCtrl::SetScrollPos(const CFX_FloatPoint& point) { 436 void CPWL_EditCtrl::SetScrollPos(const CPDF_Point& point) {
442 if (m_pEdit) 437 if (m_pEdit)
443 m_pEdit->SetScrollPos(point); 438 m_pEdit->SetScrollPos(point);
444 } 439 }
445 440
446 CFX_FloatPoint CPWL_EditCtrl::GetScrollPos() const { 441 CPDF_Point CPWL_EditCtrl::GetScrollPos() const {
447 if (m_pEdit) 442 if (m_pEdit)
448 return m_pEdit->GetScrollPos(); 443 return m_pEdit->GetScrollPos();
449 444
450 return CFX_FloatPoint(0.0f, 0.0f); 445 return CPDF_Point(0.0f, 0.0f);
451 } 446 }
452 447
453 CPDF_Font* CPWL_EditCtrl::GetCaretFont() const { 448 CPDF_Font* CPWL_EditCtrl::GetCaretFont() const {
454 int32_t nFontIndex = 0; 449 int32_t nFontIndex = 0;
455 450
456 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { 451 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) {
457 pIterator->SetAt(m_pEdit->GetCaret()); 452 pIterator->SetAt(m_pEdit->GetCaret());
458 CPVT_Word word; 453 CPVT_Word word;
459 CPVT_Section section; 454 CPVT_Section section;
460 if (pIterator->GetWord(word)) { 455 if (pIterator->GetWord(word)) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 } else { 563 } else {
569 ShowVScrollBar(TRUE); 564 ShowVScrollBar(TRUE);
570 } 565 }
571 } 566 }
572 567
573 void CPWL_EditCtrl::IOnSetScrollPosY(FX_FLOAT fy) { 568 void CPWL_EditCtrl::IOnSetScrollPosY(FX_FLOAT fy) {
574 OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&fy); 569 OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&fy);
575 } 570 }
576 571
577 void CPWL_EditCtrl::IOnSetCaret(FX_BOOL bVisible, 572 void CPWL_EditCtrl::IOnSetCaret(FX_BOOL bVisible,
578 const CFX_FloatPoint& ptHead, 573 const CPDF_Point& ptHead,
579 const CFX_FloatPoint& ptFoot, 574 const CPDF_Point& ptFoot,
580 const CPVT_WordPlace& place) { 575 const CPVT_WordPlace& place) {
581 PWL_CARET_INFO cInfo; 576 PWL_CARET_INFO cInfo;
582 cInfo.bVisible = bVisible; 577 cInfo.bVisible = bVisible;
583 cInfo.ptHead = ptHead; 578 cInfo.ptHead = ptHead;
584 cInfo.ptFoot = ptFoot; 579 cInfo.ptFoot = ptFoot;
585 580
586 OnNotify(this, PNM_SETCARETINFO, (intptr_t)&cInfo, (intptr_t)NULL); 581 OnNotify(this, PNM_SETCARETINFO, (intptr_t)&cInfo, (intptr_t)NULL);
587 } 582 }
588 583
589 void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps& secProps, 584 void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps& secProps,
590 const CPVT_WordProps& wordProps) {} 585 const CPVT_WordProps& wordProps) {}
591 586
592 void CPWL_EditCtrl::IOnContentChange(const CFX_FloatRect& rcContent) { 587 void CPWL_EditCtrl::IOnContentChange(const CPDF_Rect& rcContent) {
593 if (IsValid()) { 588 if (IsValid()) {
594 if (m_pEditNotify) { 589 if (m_pEditNotify) {
595 m_pEditNotify->OnContentChange(rcContent); 590 m_pEditNotify->OnContentChange(rcContent);
596 } 591 }
597 } 592 }
598 } 593 }
599 594
600 void CPWL_EditCtrl::IOnInvalidateRect(CFX_FloatRect* pRect) { 595 void CPWL_EditCtrl::IOnInvalidateRect(CPDF_Rect* pRect) {
601 InvalidateRect(pRect); 596 InvalidateRect(pRect);
602 } 597 }
603 598
604 int32_t CPWL_EditCtrl::GetCharSet() const { 599 int32_t CPWL_EditCtrl::GetCharSet() const {
605 return m_nCharSet < 0 ? DEFAULT_CHARSET : m_nCharSet; 600 return m_nCharSet < 0 ? DEFAULT_CHARSET : m_nCharSet;
606 } 601 }
607 602
608 void CPWL_EditCtrl::GetTextRange(const CFX_FloatRect& rect, 603 void CPWL_EditCtrl::GetTextRange(const CPDF_Rect& rect,
609 int32_t& nStartChar, 604 int32_t& nStartChar,
610 int32_t& nEndChar) const { 605 int32_t& nEndChar) const {
611 nStartChar = m_pEdit->WordPlaceToWordIndex( 606 nStartChar = m_pEdit->WordPlaceToWordIndex(
612 m_pEdit->SearchWordPlace(CFX_FloatPoint(rect.left, rect.top))); 607 m_pEdit->SearchWordPlace(CPDF_Point(rect.left, rect.top)));
613 nEndChar = m_pEdit->WordPlaceToWordIndex( 608 nEndChar = m_pEdit->WordPlaceToWordIndex(
614 m_pEdit->SearchWordPlace(CFX_FloatPoint(rect.right, rect.bottom))); 609 m_pEdit->SearchWordPlace(CPDF_Point(rect.right, rect.bottom)));
615 } 610 }
616 611
617 CFX_WideString CPWL_EditCtrl::GetText(int32_t& nStartChar, 612 CFX_WideString CPWL_EditCtrl::GetText(int32_t& nStartChar,
618 int32_t& nEndChar) const { 613 int32_t& nEndChar) const {
619 CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStartChar); 614 CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStartChar);
620 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar); 615 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar);
621 return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd)); 616 return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd));
622 } 617 }
623 618
624 void CPWL_EditCtrl::SetReadyToInput() { 619 void CPWL_EditCtrl::SetReadyToInput() {
625 if (m_bMouseDown) { 620 if (m_bMouseDown) {
626 ReleaseCapture(); 621 ReleaseCapture();
627 m_bMouseDown = FALSE; 622 m_bMouseDown = FALSE;
628 } 623 }
629 } 624 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/pdfwindow/PWL_Edit.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Icon.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698