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/cfwl_picturebox.h" | 7 #include "xfa/fwl/core/cfwl_picturebox.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "third_party/base/ptr_util.h" | 11 #include "third_party/base/ptr_util.h" |
12 | 12 |
13 CFWL_PictureBox::CFWL_PictureBox(const CFWL_App* app) : CFWL_Widget(app) {} | 13 CFWL_PictureBox::CFWL_PictureBox(const CFWL_App* app) |
| 14 : CFWL_Widget(app, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr) { |
| 15 m_rtClient.Reset(); |
| 16 m_rtImage.Reset(); |
| 17 m_matrix.SetIdentity(); |
| 18 } |
14 | 19 |
15 CFWL_PictureBox::~CFWL_PictureBox() {} | 20 CFWL_PictureBox::~CFWL_PictureBox() {} |
16 | 21 |
17 void CFWL_PictureBox::Initialize() { | 22 FWL_Type CFWL_PictureBox::GetClassID() const { |
18 ASSERT(!m_pIface); | 23 return FWL_Type::PictureBox; |
19 | |
20 m_pIface = pdfium::MakeUnique<IFWL_PictureBox>( | |
21 m_pApp, pdfium::MakeUnique<CFWL_WidgetProperties>()); | |
22 | |
23 CFWL_Widget::Initialize(); | |
24 } | 24 } |
25 | 25 |
| 26 void CFWL_PictureBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { |
| 27 if (!bAutoSize) { |
| 28 rect = m_pProperties->m_rtWidget; |
| 29 return; |
| 30 } |
| 31 |
| 32 rect.Set(0, 0, 0, 0); |
| 33 |
| 34 CFWL_Widget::GetWidgetRect(rect, true); |
| 35 } |
| 36 |
| 37 void CFWL_PictureBox::Update() { |
| 38 if (IsLocked()) |
| 39 return; |
| 40 if (!m_pProperties->m_pThemeProvider) |
| 41 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 42 |
| 43 GetClientRect(m_rtClient); |
| 44 } |
| 45 |
| 46 void CFWL_PictureBox::DrawWidget(CFX_Graphics* pGraphics, |
| 47 const CFX_Matrix* pMatrix) { |
| 48 if (!pGraphics) |
| 49 return; |
| 50 if (!m_pProperties->m_pThemeProvider) |
| 51 return; |
| 52 |
| 53 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); |
| 54 if (HasBorder()) |
| 55 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); |
| 56 if (HasEdge()) |
| 57 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
| 58 } |
| 59 |
| 60 void CFWL_PictureBox::OnDrawWidget(CFX_Graphics* pGraphics, |
| 61 const CFX_Matrix* pMatrix) { |
| 62 DrawWidget(pGraphics, pMatrix); |
| 63 } |
OLD | NEW |