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/fwl/cfwl_caret.h"
10 #include "xfa/fwl/cfwl_themebackground.h"
11 #include "xfa/fwl/cfwl_widget.h"
12 #include "xfa/fxgraphics/cfx_color.h"
13 #include "xfa/fxgraphics/cfx_path.h"
14
CFWL_CaretTP()15 CFWL_CaretTP::CFWL_CaretTP() {}
~CFWL_CaretTP()16 CFWL_CaretTP::~CFWL_CaretTP() {}
17
DrawBackground(CFWL_ThemeBackground * pParams)18 void CFWL_CaretTP::DrawBackground(CFWL_ThemeBackground* pParams) {
19 if (!pParams)
20 return;
21
22 switch (pParams->m_iPart) {
23 case CFWL_Part::Background: {
24 if (!(pParams->m_dwStates & CFWL_PartState_HightLight))
25 return;
26
27 DrawCaretBK(pParams->m_pGraphics, pParams->m_dwStates,
28 &(pParams->m_rtPart), (CFX_Color*)pParams->m_pData,
29 &(pParams->m_matrix));
30 break;
31 }
32 default:
33 break;
34 }
35 }
36
DrawCaretBK(CFX_Graphics * pGraphics,uint32_t dwStates,const CFX_RectF * pRect,CFX_Color * crFill,CFX_Matrix * pMatrix)37 void CFWL_CaretTP::DrawCaretBK(CFX_Graphics* pGraphics,
38 uint32_t dwStates,
39 const CFX_RectF* pRect,
40 CFX_Color* crFill,
41 CFX_Matrix* pMatrix) {
42 CFX_Path path;
43 CFX_RectF rect = *pRect;
44 path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
45 if (crFill) {
46 pGraphics->SetFillColor(crFill);
47 } else {
48 CFX_Color crFilltemp(ArgbEncode(255, 0, 0, 0));
49 pGraphics->SetFillColor(&crFilltemp);
50 }
51 pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
52 }
53