xref: /aosp_15_r20/external/pdfium/xfa/fxfa/cxfa_fwltheme.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
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_FXFA_CXFA_FWLTHEME_H_
8 #define XFA_FXFA_CXFA_FWLTHEME_H_
9 
10 #include <memory>
11 
12 #include "core/fxcrt/retain_ptr.h"
13 #include "core/fxcrt/widestring.h"
14 #include "fxjs/gc/heap.h"
15 #include "v8/include/cppgc/garbage-collected.h"
16 #include "v8/include/cppgc/member.h"
17 #include "v8/include/cppgc/prefinalizer.h"
18 #include "xfa/fwl/ifwl_themeprovider.h"
19 
20 class CFDE_TextOut;
21 class CXFA_FFApp;
22 class CXFA_FFDoc;
23 
24 class CXFA_FWLTheme final : public cppgc::GarbageCollected<CXFA_FWLTheme>,
25                             public IFWL_ThemeProvider {
26   CPPGC_USING_PRE_FINALIZER(CXFA_FWLTheme, PreFinalize);
27 
28  public:
29   CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
30   ~CXFA_FWLTheme() override;
31 
32   void PreFinalize();
33 
34   // IFWL_ThemeProvider:
35   void Trace(cppgc::Visitor* visitor) const override;
36   void DrawBackground(const CFWL_ThemeBackground& pParams) override;
37   void DrawText(const CFWL_ThemeText& pParams) override;
38   void CalcTextRect(const CFWL_ThemeText& pParams, CFX_RectF* pRect) override;
39   float GetCXBorderSize() const override;
40   float GetCYBorderSize() const override;
41   CFX_RectF GetUIMargin(const CFWL_ThemePart& pThemePart) const override;
42   float GetFontSize(const CFWL_ThemePart& pThemePart) const override;
43   RetainPtr<CFGAS_GEFont> GetFont(const CFWL_ThemePart& pThemePart) override;
44   RetainPtr<CFGAS_GEFont> GetFWLFont() override;
45   float GetLineHeight(const CFWL_ThemePart& pThemePart) const override;
46   float GetScrollBarWidth() const override;
47   FX_COLORREF GetTextColor(const CFWL_ThemePart& pThemePart) const override;
48   CFX_SizeF GetSpaceAboveBelow(const CFWL_ThemePart& pThemePart) const override;
49 
50   bool LoadCalendarFont(CXFA_FFDoc* doc);
51 
52  private:
53   CXFA_FWLTheme(cppgc::Heap* pHeap, CXFA_FFApp* pApp);
54 
55   std::unique_ptr<CFDE_TextOut> m_pTextOut;
56   RetainPtr<CFGAS_GEFont> m_pFWLFont;
57   RetainPtr<CFGAS_GEFont> m_pCalendarFont;
58   cppgc::Member<CXFA_FFApp> const m_pApp;
59   WideString m_wsResource;
60   CFX_RectF m_Rect;
61 };
62 
63 #endif  // XFA_FXFA_CXFA_FWLTHEME_H_
64