OLD | NEW |
| (Empty) |
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/include/fwl/theme/edittp.h" | |
8 | |
9 #include "xfa/include/fwl/basewidget/fwl_edit.h" | |
10 #include "xfa/include/fwl/core/fwl_widget.h" | |
11 | |
12 CFWL_EditTP::CFWL_EditTP() {} | |
13 CFWL_EditTP::~CFWL_EditTP() {} | |
14 | |
15 FX_BOOL CFWL_EditTP::IsValidWidget(IFWL_Widget* pWidget) { | |
16 if (!pWidget) | |
17 return FALSE; | |
18 return pWidget->GetClassID() == FWL_CLASSHASH_Edit; | |
19 } | |
20 FX_BOOL CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) { | |
21 switch (pParams->m_iPart) { | |
22 case FWL_PART_EDT_Border: { | |
23 DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); | |
24 break; | |
25 } | |
26 case FWL_PART_EDT_Edge: { | |
27 DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), | |
28 &pParams->m_rtPart, &pParams->m_matrix); | |
29 break; | |
30 } | |
31 case FWL_PART_EDT_Background: { | |
32 if (pParams->m_pPath) { | |
33 CFX_Graphics* pGraphics = pParams->m_pGraphics; | |
34 pGraphics->SaveGraphState(); | |
35 CFX_Color crSelected(FWL_GetThemeColor(m_dwThemeID) == 0 | |
36 ? FWLTHEME_COLOR_BKSelected | |
37 : FWLTHEME_COLOR_Green_BKSelected); | |
38 pGraphics->SetFillColor(&crSelected); | |
39 pGraphics->FillPath(pParams->m_pPath, FXFILL_WINDING, | |
40 &pParams->m_matrix); | |
41 pGraphics->RestoreGraphState(); | |
42 } else { | |
43 FX_BOOL bStatic = | |
44 pParams->m_dwData == FWL_PARTDATA_EDT_StaticBackground; | |
45 CFX_Path path; | |
46 path.Create(); | |
47 path.AddRectangle(pParams->m_rtPart.left, pParams->m_rtPart.top, | |
48 pParams->m_rtPart.width, pParams->m_rtPart.height); | |
49 CFX_Color cr(FWLTHEME_COLOR_Background); | |
50 if (!bStatic) { | |
51 if ((pParams->m_dwStates & FWL_PARTSTATE_EDT_Disable) == | |
52 FWL_PARTSTATE_EDT_Disable) { | |
53 cr.Set(FWLTHEME_COLOR_EDGERB1); | |
54 } else if ((pParams->m_dwStates & FWL_PARTSTATE_EDT_ReadOnly) == | |
55 FWL_PARTSTATE_EDT_ReadOnly) { | |
56 cr.Set(ArgbEncode(255, 236, 233, 216)); | |
57 } else { | |
58 cr.Set(0xFFFFFFFF); | |
59 } | |
60 } | |
61 pParams->m_pGraphics->SaveGraphState(); | |
62 pParams->m_pGraphics->SetFillColor(&cr); | |
63 pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, | |
64 &pParams->m_matrix); | |
65 pParams->m_pGraphics->RestoreGraphState(); | |
66 } | |
67 break; | |
68 } | |
69 case FWL_PART_EDT_CombTextLine: { | |
70 FX_ARGB cr = 0xFF000000; | |
71 FX_FLOAT fWidth = 1.0f; | |
72 CFX_Color crLine(cr); | |
73 pParams->m_pGraphics->SetStrokeColor(&crLine); | |
74 pParams->m_pGraphics->SetLineWidth(fWidth); | |
75 pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix); | |
76 break; | |
77 } | |
78 default: { break; } | |
79 } | |
80 return TRUE; | |
81 } | |
82 FWL_ERR CFWL_EditTP::Initialize() { | |
83 InitTTO(); | |
84 return CFWL_WidgetTP::Initialize(); | |
85 } | |
86 FWL_ERR CFWL_EditTP::Finalize() { | |
87 FinalizeTTO(); | |
88 return CFWL_WidgetTP::Finalize(); | |
89 } | |
OLD | NEW |