1 // Copyright 2014 The PDFium Authors
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_gegraphics.h"
11 #include "xfa/fgas/graphics/cfgas_gepath.h"
12 #include "xfa/fwl/cfwl_caret.h"
13 #include "xfa/fwl/cfwl_themebackground.h"
14 #include "xfa/fwl/cfwl_widget.h"
15
16 CFWL_CaretTP::CFWL_CaretTP() = default;
17
18 CFWL_CaretTP::~CFWL_CaretTP() = default;
19
DrawBackground(const CFWL_ThemeBackground & pParams)20 void CFWL_CaretTP::DrawBackground(const CFWL_ThemeBackground& pParams) {
21 switch (pParams.GetPart()) {
22 case CFWL_ThemePart::Part::kBackground: {
23 if (!(pParams.m_dwStates & CFWL_PartState::kHightLight))
24 return;
25
26 DrawCaretBK(pParams.GetGraphics(), pParams.m_dwStates, pParams.m_PartRect,
27 pParams.m_matrix);
28 break;
29 }
30 default:
31 break;
32 }
33 }
34
DrawCaretBK(CFGAS_GEGraphics * pGraphics,Mask<CFWL_PartState> dwStates,const CFX_RectF & rect,const CFX_Matrix & matrix)35 void CFWL_CaretTP::DrawCaretBK(CFGAS_GEGraphics* pGraphics,
36 Mask<CFWL_PartState> dwStates,
37 const CFX_RectF& rect,
38 const CFX_Matrix& matrix) {
39 CFGAS_GEPath path;
40 path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
41 pGraphics->SetFillColor(CFGAS_GEColor(ArgbEncode(255, 0, 0, 0)));
42 pGraphics->FillPath(path, CFX_FillRenderOptions::FillType::kWinding, matrix);
43 }
44