• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef _FWL_WIDGET_H
8 #define _FWL_WIDGET_H
9 class IFWL_Target;
10 class IFWL_ThemeProvider;
11 class CFWL_WidgetImpProperties;
12 class IFWL_DataProvider;
13 class IFWL_Widget;
14 class IFWL_WidgetDelegate;
15 class IFWL_Custom;
16 class IFWL_Proxy;
17 class IFWL_Form;
18 
19 class IFWL_DataProvider {
20  public:
~IFWL_DataProvider()21   virtual ~IFWL_DataProvider() {}
22   virtual FWL_ERR GetCaption(IFWL_Widget* pWidget,
23                              CFX_WideString& wsCaption) = 0;
24 };
25 class IFWL_Widget : public IFWL_Target {
26  public:
27   FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
28   FWL_ERR GetGlobalRect(CFX_RectF& rect);
29   FWL_ERR SetWidgetRect(const CFX_RectF& rect);
30   FWL_ERR GetClientRect(CFX_RectF& rect);
31   IFWL_Widget* GetParent();
32   FWL_ERR SetParent(IFWL_Widget* pParent);
33   IFWL_Widget* GetOwner();
34   FWL_ERR SetOwner(IFWL_Widget* pOwner);
35   IFWL_Widget* GetOuter();
36   FX_DWORD GetStyles();
37   FWL_ERR ModifyStyles(FX_DWORD dwStylesAdded, FX_DWORD dwStylesRemoved);
38   FX_DWORD GetStylesEx();
39   FWL_ERR ModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved);
40   FX_DWORD GetStates();
41   FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE);
42   FWL_ERR SetPrivateData(void* module_id,
43                          void* pData,
44                          PD_CALLBACK_FREEDATA callback);
45   void* GetPrivateData(void* module_id);
46   FWL_ERR Update();
47   FWL_ERR LockUpdate();
48   FWL_ERR UnlockUpdate();
49   FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy);
50   FWL_ERR TransformTo(IFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
51   FWL_ERR TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt);
52   FWL_ERR GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE);
53   FWL_ERR SetMatrix(const CFX_Matrix& matrix);
54   FWL_ERR DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix = NULL);
55   IFWL_ThemeProvider* GetThemeProvider();
56   FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
57   FWL_ERR SetDataProvider(IFWL_DataProvider* pDataProvider);
58   IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate);
59   IFWL_NoteThread* GetOwnerThread() const;
60   CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent);
61 };
62 class IFWL_WidgetDelegate {
63  public:
~IFWL_WidgetDelegate()64   virtual ~IFWL_WidgetDelegate() {}
65   virtual int32_t OnProcessMessage(CFWL_Message* pMessage) = 0;
66   virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent) = 0;
67   virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
68                                const CFX_Matrix* pMatrix = NULL) = 0;
69 };
70 class CFWL_WidgetImpProperties {
71  public:
CFWL_WidgetImpProperties()72   CFWL_WidgetImpProperties() {
73     m_ctmOnParent.SetIdentity();
74     m_rtWidget.Set(0, 0, 0, 0);
75     m_dwStyles = FWL_WGTSTYLE_Child;
76     m_dwStyleExes = 0;
77     m_dwStates = 0;
78     m_pThemeProvider = NULL;
79     m_pDataProvider = NULL;
80     m_pParent = NULL;
81     m_pOwner = NULL;
82   }
83   CFX_Matrix m_ctmOnParent;
84   CFX_RectF m_rtWidget;
85   FX_DWORD m_dwStyles;
86   FX_DWORD m_dwStyleExes;
87   FX_DWORD m_dwStates;
88   IFWL_ThemeProvider* m_pThemeProvider;
89   IFWL_DataProvider* m_pDataProvider;
90   IFWL_Widget* m_pParent;
91   IFWL_Widget* m_pOwner;
92 };
93 class IFWL_Custom : public IFWL_Widget {
94  public:
95   static IFWL_Custom* Create(const CFWL_WidgetImpProperties& properties,
96                              IFWL_Widget* pOuter);
97 
98   FWL_ERR SetProxy(IFWL_Proxy* pProxy);
99 
100  protected:
101   IFWL_Custom();
102 };
103 class IFWL_Proxy {
104  public:
~IFWL_Proxy()105   virtual ~IFWL_Proxy() {}
106   virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) = 0;
107   virtual FWL_ERR Update() = 0;
108 };
109 #define FWL_ACCEL_Control (1L << 0)
110 #define FWL_ACCEL_Alt (1L << 1)
111 #define FWL_ACCEL_Shift (1L << 2)
112 #define FWL_ACCEL_VirtKey (1L << 3)
113 typedef struct _FWL_ACCEL {
114   FX_DWORD dwKey;
115   FX_DWORD dwCmd;
116 } FWL_ACCEL;
117 typedef CFX_MapPtrTemplate<FX_DWORD, FX_DWORD> CFX_MapAccelerators;
118 FWL_ERR FWL_Accelerator_SetApp(CFX_MapAccelerators* pMapAccel);
119 FWL_ERR FWL_Accelerator_SetThread(CFX_MapAccelerators* pMapAccel);
120 FWL_ERR FWL_Accelerator_SetForm(IFWL_Form* pFrom,
121                                 CFX_MapAccelerators* pMapAccel);
122 FWL_ERR FWL_EnabelWidget(IFWL_Widget* widget, FX_BOOL bEnable);
123 #endif
124