1 // Copyright 2014 The PDFium Authors 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 #ifndef XFA_FWL_THEME_CFWL_WIDGETTP_H_ 8 #define XFA_FWL_THEME_CFWL_WIDGETTP_H_ 9 10 #include <array> 11 #include <memory> 12 13 #include "core/fxcrt/fx_coordinates.h" 14 #include "core/fxcrt/fx_system.h" 15 #include "core/fxcrt/retain_ptr.h" 16 #include "core/fxge/dib/fx_dib.h" 17 #include "v8/include/cppgc/garbage-collected.h" 18 #include "xfa/fwl/theme/cfwl_utils.h" 19 20 class CFGAS_GEGraphics; 21 22 namespace pdfium { 23 24 class CFDE_TextOut; 25 class CFWL_ThemeBackground; 26 class CFWL_ThemeText; 27 class IFWL_ThemeProvider; 28 29 class CFWL_WidgetTP : public cppgc::GarbageCollected<CFWL_WidgetTP> { 30 public: 31 virtual ~CFWL_WidgetTP(); 32 33 virtual void DrawBackground(const CFWL_ThemeBackground& pParams); 34 virtual void DrawText(const CFWL_ThemeText& pParams); 35 36 // Non-virtual, nothing to trace in subclasses at present. 37 void Trace(cppgc::Visitor* visitor) const; 38 39 protected: 40 struct CColorData { 41 std::array<FX_ARGB, 4> clrBorder; // Indexed by enum FWLTHEME_STATE - 1. 42 std::array<FX_ARGB, 4> clrStart; // Indexed by enum FWLTHEME_STATE - 1. 43 std::array<FX_ARGB, 4> clrEnd; // Indexed by enum FWLTHEME_STATE - 1. 44 std::array<FX_ARGB, 4> clrSign; // Indexed by enum FWLTHEME_STATE - 1. 45 }; 46 47 CFWL_WidgetTP(); 48 49 void InitializeArrowColorData(); 50 void EnsureTTOInitialized(IFWL_ThemeProvider* pProvider); 51 52 void DrawBorder(CFGAS_GEGraphics* pGraphics, 53 const CFX_RectF& rect, 54 const CFX_Matrix& matrix); 55 void FillBackground(CFGAS_GEGraphics* pGraphics, 56 const CFX_RectF& rect, 57 const CFX_Matrix& matrix); 58 void FillSolidRect(CFGAS_GEGraphics* pGraphics, 59 FX_ARGB fillColor, 60 const CFX_RectF& rect, 61 const CFX_Matrix& matrix); 62 void DrawFocus(CFGAS_GEGraphics* pGraphics, 63 const CFX_RectF& rect, 64 const CFX_Matrix& matrix); 65 void DrawArrow(CFGAS_GEGraphics* pGraphics, 66 const CFX_RectF& rect, 67 FWLTHEME_DIRECTION eDict, 68 FX_ARGB argSign, 69 const CFX_Matrix& matrix); 70 void DrawBtn(CFGAS_GEGraphics* pGraphics, 71 const CFX_RectF& rect, 72 FWLTHEME_STATE eState, 73 const CFX_Matrix& matrix); 74 void DrawArrowBtn(CFGAS_GEGraphics* pGraphics, 75 const CFX_RectF& rect, 76 FWLTHEME_DIRECTION eDict, 77 FWLTHEME_STATE eState, 78 const CFX_Matrix& matrix); 79 80 std::unique_ptr<CFDE_TextOut> m_pTextOut; 81 std::unique_ptr<CColorData> m_pColorData; 82 }; 83 84 } // namespace pdfium 85 86 // TODO(crbug.com/42271761): Remove. 87 using pdfium::CFWL_WidgetTP; 88 89 #endif // XFA_FWL_THEME_CFWL_WIDGETTP_H_ 90