1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #include "xfa/fwl/cfwl_picturebox.h"
8 
9 #include <memory>
10 
11 #include "third_party/base/ptr_util.h"
12 
CFWL_PictureBox(const CFWL_App * app)13 CFWL_PictureBox::CFWL_PictureBox(const CFWL_App* app)
14     : CFWL_Widget(app, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr) {
15 }
16 
~CFWL_PictureBox()17 CFWL_PictureBox::~CFWL_PictureBox() {}
18 
GetClassID() const19 FWL_Type CFWL_PictureBox::GetClassID() const {
20   return FWL_Type::PictureBox;
21 }
22 
Update()23 void CFWL_PictureBox::Update() {
24   if (IsLocked())
25     return;
26   if (!m_pProperties->m_pThemeProvider)
27     m_pProperties->m_pThemeProvider = GetAvailableTheme();
28 
29   m_rtClient = GetClientRect();
30 }
31 
DrawWidget(CXFA_Graphics * pGraphics,const CFX_Matrix & matrix)32 void CFWL_PictureBox::DrawWidget(CXFA_Graphics* pGraphics,
33                                  const CFX_Matrix& matrix) {
34   if (!pGraphics)
35     return;
36   if (!m_pProperties->m_pThemeProvider)
37     return;
38 
39   IFWL_ThemeProvider* pTheme = GetAvailableTheme();
40   if (HasBorder())
41     DrawBorder(pGraphics, CFWL_Part::Border, pTheme, matrix);
42 }
43 
OnDrawWidget(CXFA_Graphics * pGraphics,const CFX_Matrix & matrix)44 void CFWL_PictureBox::OnDrawWidget(CXFA_Graphics* pGraphics,
45                                    const CFX_Matrix& matrix) {
46   DrawWidget(pGraphics, matrix);
47 }
48