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   m_rtClient.Reset();
16   m_rtImage.Reset();
17   m_matrix.SetIdentity();
18 }
19 
~CFWL_PictureBox()20 CFWL_PictureBox::~CFWL_PictureBox() {}
21 
GetClassID() const22 FWL_Type CFWL_PictureBox::GetClassID() const {
23   return FWL_Type::PictureBox;
24 }
25 
Update()26 void CFWL_PictureBox::Update() {
27   if (IsLocked())
28     return;
29   if (!m_pProperties->m_pThemeProvider)
30     m_pProperties->m_pThemeProvider = GetAvailableTheme();
31 
32   m_rtClient = GetClientRect();
33 }
34 
DrawWidget(CXFA_Graphics * pGraphics,const CFX_Matrix & matrix)35 void CFWL_PictureBox::DrawWidget(CXFA_Graphics* pGraphics,
36                                  const CFX_Matrix& matrix) {
37   if (!pGraphics)
38     return;
39   if (!m_pProperties->m_pThemeProvider)
40     return;
41 
42   IFWL_ThemeProvider* pTheme = GetAvailableTheme();
43   if (HasBorder())
44     DrawBorder(pGraphics, CFWL_Part::Border, pTheme, matrix);
45 }
46 
OnDrawWidget(CXFA_Graphics * pGraphics,const CFX_Matrix & matrix)47 void CFWL_PictureBox::OnDrawWidget(CXFA_Graphics* pGraphics,
48                                    const CFX_Matrix& matrix) {
49   DrawWidget(pGraphics, matrix);
50 }
51