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/src/foxitlib.h" 8 CFWL_CaretTP::CFWL_CaretTP() {} 9 CFWL_CaretTP::~CFWL_CaretTP() {} 10 FX_BOOL CFWL_CaretTP::IsValidWidget(IFWL_Widget* pWidget) { 11 if (!pWidget) 12 return FALSE; 13 return pWidget->GetClassID() == FWL_CLASSHASH_Caret; 14 } 15 FX_BOOL CFWL_CaretTP::DrawBackground(CFWL_ThemeBackground* pParams) { 16 if (!pParams) 17 return FALSE; 18 switch (pParams->m_iPart) { 19 case FWL_PART_CAT_Background: { 20 if (!(pParams->m_dwStates & FWL_PARTSTATE_CAT_HightLight)) { 21 return TRUE; 22 } 23 DrawCaretBK(pParams->m_pGraphics, pParams->m_dwStates, 24 &(pParams->m_rtPart), (CFX_Color*)pParams->m_pData, 25 &(pParams->m_matrix)); 26 break; 27 } 28 } 29 return TRUE; 30 } 31 void CFWL_CaretTP::DrawCaretBK(CFX_Graphics* pGraphics, 32 FX_DWORD dwStates, 33 const CFX_RectF* pRect, 34 CFX_Color* crFill, 35 CFX_Matrix* pMatrix) { 36 CFX_Path path; 37 path.Create(); 38 CFX_Color crFilltemp; 39 crFill ? crFilltemp = *crFill : crFilltemp = ArgbEncode(255, 0, 0, 0); 40 CFX_RectF rect = *pRect; 41 path.AddRectangle(rect.left, rect.top, rect.width, rect.height); 42 pGraphics->SetFillColor(&crFilltemp); 43 pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); 44 } 45