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/fwl/core/ifwl_picturebox.h" | 7 #include "xfa/fwl/core/ifwl_picturebox.h" |
8 | 8 |
9 #include "third_party/base/ptr_util.h" | 9 #include "third_party/base/ptr_util.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 | 12 |
13 IFWL_PictureBox::IFWL_PictureBox( | 13 IFWL_PictureBox::IFWL_PictureBox( |
14 const IFWL_App* app, | 14 const IFWL_App* app, |
15 std::unique_ptr<CFWL_WidgetProperties> properties) | 15 std::unique_ptr<CFWL_WidgetProperties> properties) |
16 : IFWL_Widget(app, std::move(properties), nullptr) { | 16 : IFWL_Widget(app, std::move(properties), nullptr) { |
17 m_rtClient.Reset(); | 17 m_rtClient.Reset(); |
18 m_rtImage.Reset(); | 18 m_rtImage.Reset(); |
19 m_matrix.SetIdentity(); | 19 m_matrix.SetIdentity(); |
20 } | 20 } |
21 | 21 |
22 IFWL_PictureBox::~IFWL_PictureBox() {} | 22 IFWL_PictureBox::~IFWL_PictureBox() {} |
23 | 23 |
24 FWL_Type IFWL_PictureBox::GetClassID() const { | 24 FWL_Type IFWL_PictureBox::GetClassID() const { |
25 return FWL_Type::PictureBox; | 25 return FWL_Type::PictureBox; |
26 } | 26 } |
27 | 27 |
28 void IFWL_PictureBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { | 28 void IFWL_PictureBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { |
29 if (bAutoSize) { | 29 if (!bAutoSize) { |
30 rect.Set(0, 0, 0, 0); | |
31 if (!m_pProperties->m_pDataProvider) | |
32 return; | |
33 IFWL_Widget::GetWidgetRect(rect, true); | |
34 } else { | |
35 rect = m_pProperties->m_rtWidget; | 30 rect = m_pProperties->m_rtWidget; |
| 31 return; |
36 } | 32 } |
| 33 |
| 34 rect.Set(0, 0, 0, 0); |
| 35 if (!m_pProperties->m_pDataProvider) |
| 36 return; |
| 37 IFWL_Widget::GetWidgetRect(rect, true); |
37 } | 38 } |
38 | 39 |
39 void IFWL_PictureBox::Update() { | 40 void IFWL_PictureBox::Update() { |
40 if (IsLocked()) { | 41 if (IsLocked()) |
41 return; | 42 return; |
42 } | 43 if (!m_pProperties->m_pThemeProvider) |
43 if (!m_pProperties->m_pThemeProvider) { | |
44 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 44 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
45 } | 45 |
46 GetClientRect(m_rtClient); | 46 GetClientRect(m_rtClient); |
47 } | 47 } |
48 | 48 |
49 void IFWL_PictureBox::DrawWidget(CFX_Graphics* pGraphics, | 49 void IFWL_PictureBox::DrawWidget(CFX_Graphics* pGraphics, |
50 const CFX_Matrix* pMatrix) { | 50 const CFX_Matrix* pMatrix) { |
51 if (!pGraphics) | 51 if (!pGraphics) |
52 return; | 52 return; |
53 if (!m_pProperties->m_pThemeProvider) | 53 if (!m_pProperties->m_pThemeProvider) |
54 return; | 54 return; |
| 55 |
55 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); | 56 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); |
56 if (HasBorder()) { | 57 if (HasBorder()) |
57 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); | 58 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); |
58 } | 59 if (HasEdge()) |
59 if (HasEdge()) { | |
60 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 60 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
61 } | |
62 DrawBkground(pGraphics, pTheme, pMatrix); | |
63 } | |
64 | |
65 void IFWL_PictureBox::DrawBkground(CFX_Graphics* pGraphics, | |
66 IFWL_ThemeProvider* pTheme, | |
67 const CFX_Matrix* pMatrix) { | |
68 return; | |
69 } | 61 } |
70 | 62 |
71 void IFWL_PictureBox::OnDrawWidget(CFX_Graphics* pGraphics, | 63 void IFWL_PictureBox::OnDrawWidget(CFX_Graphics* pGraphics, |
72 const CFX_Matrix* pMatrix) { | 64 const CFX_Matrix* pMatrix) { |
73 DrawWidget(pGraphics, pMatrix); | 65 DrawWidget(pGraphics, pMatrix); |
74 } | 66 } |
OLD | NEW |