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_ffimageedit.h" | 7 #include "xfa/fxfa/app/xfa_ffimageedit.h" |
8 | 8 |
9 #include "xfa/fwl/core/cfwl_message.h" | 9 #include "xfa/fwl/core/cfwl_message.h" |
10 #include "xfa/fwl/core/cfwl_picturebox.h" | 10 #include "xfa/fwl/core/cfwl_picturebox.h" |
11 #include "xfa/fwl/core/fwl_noteimp.h" | 11 #include "xfa/fwl/core/fwl_noteimp.h" |
12 #include "xfa/fwl/core/ifwl_app.h" | 12 #include "xfa/fwl/core/ifwl_app.h" |
13 #include "xfa/fxfa/app/xfa_fffield.h" | 13 #include "xfa/fxfa/app/xfa_fffield.h" |
14 #include "xfa/fxfa/xfa_ffdoc.h" | 14 #include "xfa/fxfa/xfa_ffdoc.h" |
15 #include "xfa/fxfa/xfa_ffdocview.h" | 15 #include "xfa/fxfa/xfa_ffdocview.h" |
16 #include "xfa/fxfa/xfa_ffpageview.h" | 16 #include "xfa/fxfa/xfa_ffpageview.h" |
17 #include "xfa/fxfa/xfa_ffwidget.h" | 17 #include "xfa/fxfa/xfa_ffwidget.h" |
18 | 18 |
19 CXFA_FFImageEdit::CXFA_FFImageEdit(CXFA_FFPageView* pPageView, | 19 CXFA_FFImageEdit::CXFA_FFImageEdit(CXFA_FFPageView* pPageView, |
20 CXFA_WidgetAcc* pDataAcc) | 20 CXFA_WidgetAcc* pDataAcc) |
21 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(nullptr) {} | 21 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(nullptr) {} |
22 CXFA_FFImageEdit::~CXFA_FFImageEdit() { | 22 CXFA_FFImageEdit::~CXFA_FFImageEdit() { |
23 CXFA_FFImageEdit::UnloadWidget(); | 23 CXFA_FFImageEdit::UnloadWidget(); |
24 } | 24 } |
25 FX_BOOL CXFA_FFImageEdit::LoadWidget() { | 25 bool CXFA_FFImageEdit::LoadWidget() { |
26 CFWL_PictureBox* pPictureBox = new CFWL_PictureBox(GetFWLApp()); | 26 CFWL_PictureBox* pPictureBox = new CFWL_PictureBox(GetFWLApp()); |
27 pPictureBox->Initialize(); | 27 pPictureBox->Initialize(); |
28 m_pNormalWidget = pPictureBox; | 28 m_pNormalWidget = pPictureBox; |
29 m_pNormalWidget->SetLayoutItem(this); | 29 m_pNormalWidget->SetLayoutItem(this); |
30 | 30 |
31 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); | 31 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); |
32 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); | 32 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); |
33 pNoteDriver->RegisterEventTarget(pWidget, pWidget); | 33 pNoteDriver->RegisterEventTarget(pWidget, pWidget); |
34 | 34 |
35 m_pOldDelegate = pPictureBox->GetDelegate(); | 35 m_pOldDelegate = pPictureBox->GetDelegate(); |
36 pPictureBox->SetDelegate(this); | 36 pPictureBox->SetDelegate(this); |
37 | 37 |
38 CXFA_FFField::LoadWidget(); | 38 CXFA_FFField::LoadWidget(); |
39 if (m_pDataAcc->GetImageEditImage()) { | 39 if (m_pDataAcc->GetImageEditImage()) { |
40 return TRUE; | 40 return true; |
41 } | 41 } |
42 UpdateFWLData(); | 42 UpdateFWLData(); |
43 return TRUE; | 43 return true; |
44 } | 44 } |
45 void CXFA_FFImageEdit::UnloadWidget() { | 45 void CXFA_FFImageEdit::UnloadWidget() { |
46 m_pDataAcc->SetImageEditImage(nullptr); | 46 m_pDataAcc->SetImageEditImage(nullptr); |
47 CXFA_FFField::UnloadWidget(); | 47 CXFA_FFField::UnloadWidget(); |
48 } | 48 } |
49 void CXFA_FFImageEdit::RenderWidget(CFX_Graphics* pGS, | 49 void CXFA_FFImageEdit::RenderWidget(CFX_Graphics* pGS, |
50 CFX_Matrix* pMatrix, | 50 CFX_Matrix* pMatrix, |
51 uint32_t dwStatus) { | 51 uint32_t dwStatus) { |
52 if (!IsMatchVisibleStatus(dwStatus)) { | 52 if (!IsMatchVisibleStatus(dwStatus)) { |
53 return; | 53 return; |
(...skipping 23 matching lines...) Expand all Loading... |
77 } | 77 } |
78 } | 78 } |
79 int32_t iImageXDpi = 0; | 79 int32_t iImageXDpi = 0; |
80 int32_t iImageYDpi = 0; | 80 int32_t iImageYDpi = 0; |
81 m_pDataAcc->GetImageEditDpi(iImageXDpi, iImageYDpi); | 81 m_pDataAcc->GetImageEditDpi(iImageXDpi, iImageYDpi); |
82 XFA_DrawImage(pGS, rtImage, &mtRotate, pDIBitmap, iAspect, iImageXDpi, | 82 XFA_DrawImage(pGS, rtImage, &mtRotate, pDIBitmap, iAspect, iImageXDpi, |
83 iImageYDpi, iHorzAlign, iVertAlign); | 83 iImageYDpi, iHorzAlign, iVertAlign); |
84 } | 84 } |
85 } | 85 } |
86 | 86 |
87 FX_BOOL CXFA_FFImageEdit::OnLButtonDown(uint32_t dwFlags, | 87 bool CXFA_FFImageEdit::OnLButtonDown(uint32_t dwFlags, |
88 FX_FLOAT fx, | 88 FX_FLOAT fx, |
89 FX_FLOAT fy) { | 89 FX_FLOAT fy) { |
90 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) | 90 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) |
91 return FALSE; | 91 return false; |
92 | 92 |
93 if (!PtInActiveRect(fx, fy)) | 93 if (!PtInActiveRect(fx, fy)) |
94 return FALSE; | 94 return false; |
95 | 95 |
96 SetButtonDown(TRUE); | 96 SetButtonDown(true); |
97 CFWL_MsgMouse ms; | 97 CFWL_MsgMouse ms; |
98 ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; | 98 ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; |
99 ms.m_dwFlags = dwFlags; | 99 ms.m_dwFlags = dwFlags; |
100 ms.m_fx = fx; | 100 ms.m_fx = fx; |
101 ms.m_fy = fy; | 101 ms.m_fy = fy; |
102 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); | 102 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); |
103 FWLToClient(ms.m_fx, ms.m_fy); | 103 FWLToClient(ms.m_fx, ms.m_fy); |
104 TranslateFWLMessage(&ms); | 104 TranslateFWLMessage(&ms); |
105 return TRUE; | 105 return true; |
106 } | 106 } |
107 | 107 |
108 void CXFA_FFImageEdit::SetFWLRect() { | 108 void CXFA_FFImageEdit::SetFWLRect() { |
109 if (!m_pNormalWidget) { | 109 if (!m_pNormalWidget) { |
110 return; | 110 return; |
111 } | 111 } |
112 CFX_RectF rtUIMargin; | 112 CFX_RectF rtUIMargin; |
113 m_pDataAcc->GetUIMargin(rtUIMargin); | 113 m_pDataAcc->GetUIMargin(rtUIMargin); |
114 CFX_RectF rtImage(m_rtUI); | 114 CFX_RectF rtImage(m_rtUI); |
115 rtImage.Deflate(rtUIMargin.left, rtUIMargin.top, rtUIMargin.width, | 115 rtImage.Deflate(rtUIMargin.left, rtUIMargin.top, rtUIMargin.width, |
116 rtUIMargin.height); | 116 rtUIMargin.height); |
117 m_pNormalWidget->SetWidgetRect(rtImage); | 117 m_pNormalWidget->SetWidgetRect(rtImage); |
118 } | 118 } |
119 FX_BOOL CXFA_FFImageEdit::CommitData() { | 119 bool CXFA_FFImageEdit::CommitData() { |
120 return TRUE; | 120 return true; |
121 } | 121 } |
122 FX_BOOL CXFA_FFImageEdit::UpdateFWLData() { | 122 bool CXFA_FFImageEdit::UpdateFWLData() { |
123 m_pDataAcc->SetImageEditImage(nullptr); | 123 m_pDataAcc->SetImageEditImage(nullptr); |
124 m_pDataAcc->LoadImageEditImage(); | 124 m_pDataAcc->LoadImageEditImage(); |
125 return TRUE; | 125 return true; |
126 } | 126 } |
127 | 127 |
128 void CXFA_FFImageEdit::OnProcessMessage(CFWL_Message* pMessage) { | 128 void CXFA_FFImageEdit::OnProcessMessage(CFWL_Message* pMessage) { |
129 m_pOldDelegate->OnProcessMessage(pMessage); | 129 m_pOldDelegate->OnProcessMessage(pMessage); |
130 } | 130 } |
131 | 131 |
132 void CXFA_FFImageEdit::OnProcessEvent(CFWL_Event* pEvent) { | 132 void CXFA_FFImageEdit::OnProcessEvent(CFWL_Event* pEvent) { |
133 CXFA_FFField::OnProcessEvent(pEvent); | 133 CXFA_FFField::OnProcessEvent(pEvent); |
134 m_pOldDelegate->OnProcessEvent(pEvent); | 134 m_pOldDelegate->OnProcessEvent(pEvent); |
135 } | 135 } |
136 | 136 |
137 void CXFA_FFImageEdit::OnDrawWidget(CFX_Graphics* pGraphics, | 137 void CXFA_FFImageEdit::OnDrawWidget(CFX_Graphics* pGraphics, |
138 const CFX_Matrix* pMatrix) { | 138 const CFX_Matrix* pMatrix) { |
139 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); | 139 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); |
140 } | 140 } |
OLD | NEW |