Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fwl / src / theme / carettp.cpp
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #include "../../../foxitlib.h"\r
8 CFWL_CaretTP::CFWL_CaretTP()\r
9 {\r
10 }\r
11 CFWL_CaretTP::~CFWL_CaretTP()\r
12 {\r
13 }\r
14 FX_BOOL CFWL_CaretTP::IsValidWidget(IFWL_Widget *pWidget)\r
15 {\r
16     _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);\r
17     return pWidget->GetClassID() == FWL_CLASSHASH_Caret;\r
18 }\r
19 FX_BOOL CFWL_CaretTP::DrawBackground(CFWL_ThemeBackground *pParams)\r
20 {\r
21     _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);\r
22     switch(pParams->m_iPart) {\r
23         case FWL_PART_CAT_Background: {\r
24                 if (!(pParams->m_dwStates & FWL_PARTSTATE_CAT_HightLight)) {\r
25                     return TRUE;\r
26                 }\r
27                 DrawCaretBK(pParams->m_pGraphics, pParams->m_dwStates, &(pParams->m_rtPart), (CFX_Color *)pParams->m_pData, &(pParams->m_matrix));\r
28                 break;\r
29             }\r
30     }\r
31     return TRUE;\r
32 }\r
33 void CFWL_CaretTP::DrawCaretBK(CFX_Graphics *pGraphics, FX_DWORD dwStates, const CFX_RectF *pRect, CFX_Color *crFill, CFX_Matrix *pMatrix)\r
34 {\r
35     CFX_Path path;\r
36     path.Create();\r
37     CFX_Color crFilltemp;\r
38     crFill ? crFilltemp = *crFill : crFilltemp = ArgbEncode(255, 0, 0, 0);\r
39     CFX_RectF rect = *pRect;\r
40     path.AddRectangle(rect.left, rect.top, rect.width, rect.height);\r
41     pGraphics->SetFillColor(&crFilltemp);\r
42     pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);\r
43 }\r