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/theme/cfwl_carettp.h"
8
9 #include "xfa/fgas/graphics/cfgas_gecolor.h"
10 #include "xfa/fgas/graphics/cfgas_gepath.h"
11 #include "xfa/fwl/cfwl_caret.h"
12 #include "xfa/fwl/cfwl_themebackground.h"
13 #include "xfa/fwl/cfwl_widget.h"
14
15 CFWL_CaretTP::CFWL_CaretTP() = default;
16
17 CFWL_CaretTP::~CFWL_CaretTP() = default;
18
DrawBackground(const CFWL_ThemeBackground & pParams)19 void CFWL_CaretTP::DrawBackground(const CFWL_ThemeBackground& pParams) {
20 switch (pParams.m_iPart) {
21 case CFWL_Part::Background: {
22 if (!(pParams.m_dwStates & CFWL_PartState_HightLight))
23 return;
24
25 DrawCaretBK(pParams.m_pGraphics.Get(), pParams.m_dwStates,
26 pParams.m_PartRect, pParams.m_matrix);
27 break;
28 }
29 default:
30 break;
31 }
32 }
33
DrawCaretBK(CFGAS_GEGraphics * pGraphics,uint32_t dwStates,const CFX_RectF & rect,const CFX_Matrix & matrix)34 void CFWL_CaretTP::DrawCaretBK(CFGAS_GEGraphics* pGraphics,
35 uint32_t dwStates,
36 const CFX_RectF& rect,
37 const CFX_Matrix& matrix) {
38 CFGAS_GEPath path;
39 path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
40 pGraphics->SetFillColor(CFGAS_GEColor(ArgbEncode(255, 0, 0, 0)));
41 pGraphics->FillPath(&path, CFX_FillRenderOptions::FillType::kWinding,
42 &matrix);
43 }
44