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