OLD | NEW |
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/fxfa/app/xfa_fffield.h" | 7 #include "xfa/fxfa/app/xfa_fffield.h" |
8 | 8 |
9 #include "xfa/fwl/basewidget/ifwl_edit.h" | 9 #include "xfa/fwl/basewidget/ifwl_edit.h" |
10 #include "xfa/fwl/core/cfwl_message.h" | 10 #include "xfa/fwl/core/cfwl_message.h" |
11 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 11 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
12 #include "xfa/fwl/lightwidget/cfwl_edit.h" | 12 #include "xfa/fwl/lightwidget/cfwl_edit.h" |
13 #include "xfa/fwl/lightwidget/cfwl_picturebox.h" | 13 #include "xfa/fwl/lightwidget/cfwl_picturebox.h" |
14 #include "xfa/fxfa/app/xfa_fwltheme.h" | 14 #include "xfa/fxfa/app/xfa_fwltheme.h" |
15 #include "xfa/fxfa/app/xfa_textlayout.h" | 15 #include "xfa/fxfa/app/xfa_textlayout.h" |
16 #include "xfa/fxfa/include/xfa_ffapp.h" | 16 #include "xfa/fxfa/include/xfa_ffapp.h" |
17 #include "xfa/fxfa/include/xfa_ffdoc.h" | 17 #include "xfa/fxfa/include/xfa_ffdoc.h" |
18 #include "xfa/fxfa/include/xfa_ffdocview.h" | 18 #include "xfa/fxfa/include/xfa_ffdocview.h" |
19 #include "xfa/fxfa/include/xfa_ffpageview.h" | 19 #include "xfa/fxfa/include/xfa_ffpageview.h" |
20 #include "xfa/fxfa/include/xfa_ffwidget.h" | 20 #include "xfa/fxfa/include/xfa_ffwidget.h" |
21 #include "xfa/fxgraphics/cfx_color.h" | 21 #include "xfa/fxgraphics/cfx_color.h" |
22 #include "xfa/fxgraphics/cfx_path.h" | 22 #include "xfa/fxgraphics/cfx_path.h" |
23 | 23 |
24 CXFA_FFField::CXFA_FFField(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) | 24 CXFA_FFField::CXFA_FFField(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) |
25 : CXFA_FFWidget(pPageView, pDataAcc), m_pNormalWidget(NULL) { | 25 : CXFA_FFWidget(pPageView, pDataAcc), m_pNormalWidget(nullptr) { |
26 m_rtUI.Set(0, 0, 0, 0); | 26 m_rtUI.Set(0, 0, 0, 0); |
27 m_rtCaption.Set(0, 0, 0, 0); | 27 m_rtCaption.Set(0, 0, 0, 0); |
28 } | 28 } |
29 CXFA_FFField::~CXFA_FFField() { | 29 CXFA_FFField::~CXFA_FFField() { |
30 CXFA_FFField::UnloadWidget(); | 30 CXFA_FFField::UnloadWidget(); |
31 } | 31 } |
32 | 32 |
33 FX_BOOL CXFA_FFField::GetBBox(CFX_RectF& rtBox, | 33 FX_BOOL CXFA_FFField::GetBBox(CFX_RectF& rtBox, |
34 uint32_t dwStatus, | 34 uint32_t dwStatus, |
35 FX_BOOL bDrawFocus) { | 35 FX_BOOL bDrawFocus) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 CFX_RectF rtWidget; | 159 CFX_RectF rtWidget; |
160 GetRectWithoutRotate(rtWidget); | 160 GetRectWithoutRotate(rtWidget); |
161 CXFA_Margin mgWidget = m_pDataAcc->GetMargin(); | 161 CXFA_Margin mgWidget = m_pDataAcc->GetMargin(); |
162 if (mgWidget) { | 162 if (mgWidget) { |
163 CXFA_LayoutItem* pItem = this; | 163 CXFA_LayoutItem* pItem = this; |
164 FX_FLOAT fLeftInset = 0, fRightInset = 0, fTopInset = 0, fBottomInset = 0; | 164 FX_FLOAT fLeftInset = 0, fRightInset = 0, fTopInset = 0, fBottomInset = 0; |
165 mgWidget.GetLeftInset(fLeftInset); | 165 mgWidget.GetLeftInset(fLeftInset); |
166 mgWidget.GetRightInset(fRightInset); | 166 mgWidget.GetRightInset(fRightInset); |
167 mgWidget.GetTopInset(fTopInset); | 167 mgWidget.GetTopInset(fTopInset); |
168 mgWidget.GetBottomInset(fBottomInset); | 168 mgWidget.GetBottomInset(fBottomInset); |
169 if (pItem->GetPrev() == NULL && pItem->GetNext() == NULL) { | 169 if (!pItem->GetPrev() && !pItem->GetNext()) { |
170 rtWidget.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); | 170 rtWidget.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); |
171 } else { | 171 } else { |
172 if (pItem->GetPrev() == NULL) { | 172 if (!pItem->GetPrev()) { |
173 rtWidget.Deflate(fLeftInset, fTopInset, fRightInset, 0); | 173 rtWidget.Deflate(fLeftInset, fTopInset, fRightInset, 0); |
174 } else if (pItem->GetNext() == NULL) { | 174 } else if (!pItem->GetNext()) { |
175 rtWidget.Deflate(fLeftInset, 0, fRightInset, fBottomInset); | 175 rtWidget.Deflate(fLeftInset, 0, fRightInset, fBottomInset); |
176 } else { | 176 } else { |
177 rtWidget.Deflate(fLeftInset, 0, fRightInset, 0); | 177 rtWidget.Deflate(fLeftInset, 0, fRightInset, 0); |
178 } | 178 } |
179 } | 179 } |
180 } | 180 } |
181 XFA_ATTRIBUTEENUM iCapPlacement = XFA_ATTRIBUTEENUM_Unknown; | 181 XFA_ATTRIBUTEENUM iCapPlacement = XFA_ATTRIBUTEENUM_Unknown; |
182 FX_FLOAT fCapReserve = 0; | 182 FX_FLOAT fCapReserve = 0; |
183 CXFA_Caption caption = m_pDataAcc->GetCaption(); | 183 CXFA_Caption caption = m_pDataAcc->GetCaption(); |
184 if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { | 184 if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { |
185 iCapPlacement = (XFA_ATTRIBUTEENUM)caption.GetPlacementType(); | 185 iCapPlacement = (XFA_ATTRIBUTEENUM)caption.GetPlacementType(); |
186 if (iCapPlacement == XFA_ATTRIBUTEENUM_Top && GetPrev()) { | 186 if (iCapPlacement == XFA_ATTRIBUTEENUM_Top && GetPrev()) { |
187 m_rtCaption.Set(0, 0, 0, 0); | 187 m_rtCaption.Set(0, 0, 0, 0); |
188 } else if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom && GetNext()) { | 188 } else if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom && GetNext()) { |
189 m_rtCaption.Set(0, 0, 0, 0); | 189 m_rtCaption.Set(0, 0, 0, 0); |
190 } else { | 190 } else { |
191 fCapReserve = caption.GetReserve(); | 191 fCapReserve = caption.GetReserve(); |
192 CXFA_LayoutItem* pItem = this; | 192 CXFA_LayoutItem* pItem = this; |
193 if (pItem->GetPrev() == NULL && pItem->GetNext() == NULL) { | 193 if (!pItem->GetPrev() && !pItem->GetNext()) { |
194 m_rtCaption.Set(rtWidget.left, rtWidget.top, rtWidget.width, | 194 m_rtCaption.Set(rtWidget.left, rtWidget.top, rtWidget.width, |
195 rtWidget.height); | 195 rtWidget.height); |
196 } else { | 196 } else { |
197 pItem = pItem->GetFirst(); | 197 pItem = pItem->GetFirst(); |
198 pItem->GetRect(m_rtCaption); | 198 pItem->GetRect(m_rtCaption); |
199 pItem = pItem->GetNext(); | 199 pItem = pItem->GetNext(); |
200 while (pItem) { | 200 while (pItem) { |
201 CFX_RectF rtRect; | 201 CFX_RectF rtRect; |
202 pItem->GetRect(rtRect); | 202 pItem->GetRect(rtRect); |
203 m_rtCaption.height += rtRect.Height(); | 203 m_rtCaption.height += rtRect.Height(); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 } | 343 } |
344 m_pNormalWidget->SetWidgetRect(rtUi); | 344 m_pNormalWidget->SetWidgetRect(rtUi); |
345 } | 345 } |
346 FX_BOOL CXFA_FFField::OnMouseEnter() { | 346 FX_BOOL CXFA_FFField::OnMouseEnter() { |
347 if (!m_pNormalWidget) { | 347 if (!m_pNormalWidget) { |
348 return FALSE; | 348 return FALSE; |
349 } | 349 } |
350 CFWL_MsgMouse ms; | 350 CFWL_MsgMouse ms; |
351 ms.m_dwCmd = FWL_MouseCommand::Enter; | 351 ms.m_dwCmd = FWL_MouseCommand::Enter; |
352 ms.m_pDstTarget = m_pNormalWidget->m_pIface; | 352 ms.m_pDstTarget = m_pNormalWidget->m_pIface; |
353 ms.m_pSrcTarget = NULL; | 353 ms.m_pSrcTarget = nullptr; |
354 TranslateFWLMessage(&ms); | 354 TranslateFWLMessage(&ms); |
355 return TRUE; | 355 return TRUE; |
356 } | 356 } |
357 FX_BOOL CXFA_FFField::OnMouseExit() { | 357 FX_BOOL CXFA_FFField::OnMouseExit() { |
358 if (!m_pNormalWidget) { | 358 if (!m_pNormalWidget) { |
359 return FALSE; | 359 return FALSE; |
360 } | 360 } |
361 CFWL_MsgMouse ms; | 361 CFWL_MsgMouse ms; |
362 ms.m_dwCmd = FWL_MouseCommand::Leave; | 362 ms.m_dwCmd = FWL_MouseCommand::Leave; |
363 ms.m_pDstTarget = m_pNormalWidget->m_pIface; | 363 ms.m_pDstTarget = m_pNormalWidget->m_pIface; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 return TRUE; | 522 return TRUE; |
523 } | 523 } |
524 | 524 |
525 FX_BOOL CXFA_FFField::OnSetFocus(CXFA_FFWidget* pOldWidget) { | 525 FX_BOOL CXFA_FFField::OnSetFocus(CXFA_FFWidget* pOldWidget) { |
526 CXFA_FFWidget::OnSetFocus(pOldWidget); | 526 CXFA_FFWidget::OnSetFocus(pOldWidget); |
527 if (!m_pNormalWidget) { | 527 if (!m_pNormalWidget) { |
528 return FALSE; | 528 return FALSE; |
529 } | 529 } |
530 CFWL_MsgSetFocus ms; | 530 CFWL_MsgSetFocus ms; |
531 ms.m_pDstTarget = m_pNormalWidget->m_pIface; | 531 ms.m_pDstTarget = m_pNormalWidget->m_pIface; |
532 ms.m_pSrcTarget = NULL; | 532 ms.m_pSrcTarget = nullptr; |
533 TranslateFWLMessage(&ms); | 533 TranslateFWLMessage(&ms); |
534 m_dwStatus |= XFA_WidgetStatus_Focused; | 534 m_dwStatus |= XFA_WidgetStatus_Focused; |
535 AddInvalidateRect(); | 535 AddInvalidateRect(); |
536 return TRUE; | 536 return TRUE; |
537 } | 537 } |
538 FX_BOOL CXFA_FFField::OnKillFocus(CXFA_FFWidget* pNewWidget) { | 538 FX_BOOL CXFA_FFField::OnKillFocus(CXFA_FFWidget* pNewWidget) { |
539 if (!m_pNormalWidget) { | 539 if (!m_pNormalWidget) { |
540 return CXFA_FFWidget::OnKillFocus(pNewWidget); | 540 return CXFA_FFWidget::OnKillFocus(pNewWidget); |
541 } | 541 } |
542 CFWL_MsgKillFocus ms; | 542 CFWL_MsgKillFocus ms; |
543 ms.m_pDstTarget = m_pNormalWidget->m_pIface; | 543 ms.m_pDstTarget = m_pNormalWidget->m_pIface; |
544 ms.m_pSrcTarget = NULL; | 544 ms.m_pSrcTarget = nullptr; |
545 TranslateFWLMessage(&ms); | 545 TranslateFWLMessage(&ms); |
546 m_dwStatus &= ~XFA_WidgetStatus_Focused; | 546 m_dwStatus &= ~XFA_WidgetStatus_Focused; |
547 AddInvalidateRect(); | 547 AddInvalidateRect(); |
548 CXFA_FFWidget::OnKillFocus(pNewWidget); | 548 CXFA_FFWidget::OnKillFocus(pNewWidget); |
549 return TRUE; | 549 return TRUE; |
550 } | 550 } |
551 FX_BOOL CXFA_FFField::OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) { | 551 FX_BOOL CXFA_FFField::OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) { |
552 if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { | 552 if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { |
553 return FALSE; | 553 return FALSE; |
554 } | 554 } |
555 CFWL_MsgKey ms; | 555 CFWL_MsgKey ms; |
556 ms.m_dwCmd = FWL_KeyCommand::KeyDown; | 556 ms.m_dwCmd = FWL_KeyCommand::KeyDown; |
557 ms.m_dwFlags = dwFlags; | 557 ms.m_dwFlags = dwFlags; |
558 ms.m_dwKeyCode = dwKeyCode; | 558 ms.m_dwKeyCode = dwKeyCode; |
559 ms.m_pDstTarget = m_pNormalWidget->m_pIface; | 559 ms.m_pDstTarget = m_pNormalWidget->m_pIface; |
560 ms.m_pSrcTarget = NULL; | 560 ms.m_pSrcTarget = nullptr; |
561 TranslateFWLMessage(&ms); | 561 TranslateFWLMessage(&ms); |
562 return TRUE; | 562 return TRUE; |
563 } | 563 } |
564 FX_BOOL CXFA_FFField::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) { | 564 FX_BOOL CXFA_FFField::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) { |
565 if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { | 565 if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { |
566 return FALSE; | 566 return FALSE; |
567 } | 567 } |
568 CFWL_MsgKey ms; | 568 CFWL_MsgKey ms; |
569 ms.m_dwCmd = FWL_KeyCommand::KeyUp; | 569 ms.m_dwCmd = FWL_KeyCommand::KeyUp; |
570 ms.m_dwFlags = dwFlags; | 570 ms.m_dwFlags = dwFlags; |
571 ms.m_dwKeyCode = dwKeyCode; | 571 ms.m_dwKeyCode = dwKeyCode; |
572 ms.m_pDstTarget = m_pNormalWidget->m_pIface; | 572 ms.m_pDstTarget = m_pNormalWidget->m_pIface; |
573 ms.m_pSrcTarget = NULL; | 573 ms.m_pSrcTarget = nullptr; |
574 TranslateFWLMessage(&ms); | 574 TranslateFWLMessage(&ms); |
575 return TRUE; | 575 return TRUE; |
576 } | 576 } |
577 FX_BOOL CXFA_FFField::OnChar(uint32_t dwChar, uint32_t dwFlags) { | 577 FX_BOOL CXFA_FFField::OnChar(uint32_t dwChar, uint32_t dwFlags) { |
578 if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { | 578 if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { |
579 return FALSE; | 579 return FALSE; |
580 } | 580 } |
581 if (dwChar == FWL_VKEY_Tab) { | 581 if (dwChar == FWL_VKEY_Tab) { |
582 return TRUE; | 582 return TRUE; |
583 } | 583 } |
584 if (!m_pNormalWidget) { | 584 if (!m_pNormalWidget) { |
585 return FALSE; | 585 return FALSE; |
586 } | 586 } |
587 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { | 587 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { |
588 return FALSE; | 588 return FALSE; |
589 } | 589 } |
590 CFWL_MsgKey ms; | 590 CFWL_MsgKey ms; |
591 ms.m_dwCmd = FWL_KeyCommand::Char; | 591 ms.m_dwCmd = FWL_KeyCommand::Char; |
592 ms.m_dwFlags = dwFlags; | 592 ms.m_dwFlags = dwFlags; |
593 ms.m_dwKeyCode = dwChar; | 593 ms.m_dwKeyCode = dwChar; |
594 ms.m_pDstTarget = m_pNormalWidget->m_pIface; | 594 ms.m_pDstTarget = m_pNormalWidget->m_pIface; |
595 ms.m_pSrcTarget = NULL; | 595 ms.m_pSrcTarget = nullptr; |
596 TranslateFWLMessage(&ms); | 596 TranslateFWLMessage(&ms); |
597 return TRUE; | 597 return TRUE; |
598 } | 598 } |
599 FWL_WidgetHit CXFA_FFField::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { | 599 FWL_WidgetHit CXFA_FFField::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { |
600 if (m_pNormalWidget) { | 600 if (m_pNormalWidget) { |
601 FX_FLOAT ffx = fx, ffy = fy; | 601 FX_FLOAT ffx = fx, ffy = fy; |
602 FWLToClient(ffx, ffy); | 602 FWLToClient(ffx, ffy); |
603 if (m_pNormalWidget->HitTest(ffx, ffy) != FWL_WidgetHit::Unknown) | 603 if (m_pNormalWidget->HitTest(ffx, ffy) != FWL_WidgetHit::Unknown) |
604 return FWL_WidgetHit::Client; | 604 return FWL_WidgetHit::Client; |
605 } | 605 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 if (!pAcc) { | 682 if (!pAcc) { |
683 return CalculateWidgetAcc(m_pDataAcc); | 683 return CalculateWidgetAcc(m_pDataAcc); |
684 } | 684 } |
685 if (CalculateWidgetAcc(pAcc) == 0) { | 685 if (CalculateWidgetAcc(pAcc) == 0) { |
686 return 0; | 686 return 0; |
687 } | 687 } |
688 CXFA_Node* pNode = pAcc->GetExclGroupFirstMember(); | 688 CXFA_Node* pNode = pAcc->GetExclGroupFirstMember(); |
689 if (!pNode) { | 689 if (!pNode) { |
690 return 1; | 690 return 1; |
691 } | 691 } |
692 CXFA_WidgetAcc* pWidgetAcc = NULL; | 692 CXFA_WidgetAcc* pWidgetAcc = nullptr; |
693 while (pNode) { | 693 while (pNode) { |
694 pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()); | 694 pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()); |
695 if (!pWidgetAcc) { | 695 if (!pWidgetAcc) { |
696 return 1; | 696 return 1; |
697 } | 697 } |
698 if (CalculateWidgetAcc(pWidgetAcc) == 0) { | 698 if (CalculateWidgetAcc(pWidgetAcc) == 0) { |
699 return 0; | 699 return 0; |
700 } | 700 } |
701 pNode = pWidgetAcc->GetExclGroupNextMember(pNode); | 701 pNode = pWidgetAcc->GetExclGroupNextMember(pNode); |
702 } | 702 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam); | 818 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam); |
819 break; | 819 break; |
820 } | 820 } |
821 default: | 821 default: |
822 break; | 822 break; |
823 } | 823 } |
824 } | 824 } |
825 | 825 |
826 void CXFA_FFField::OnDrawWidget(CFX_Graphics* pGraphics, | 826 void CXFA_FFField::OnDrawWidget(CFX_Graphics* pGraphics, |
827 const CFX_Matrix* pMatrix) {} | 827 const CFX_Matrix* pMatrix) {} |
OLD | NEW |