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