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