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/fwl/lightwidget/cfwl_widget.h" | |
8 | |
9 #include "xfa/fde/tto/fde_textout.h" | |
10 #include "xfa/fwl/core/cfwl_themetext.h" | |
11 #include "xfa/fwl/core/cfwl_widgetmgr.h" | |
12 #include "xfa/fwl/core/fwl_noteimp.h" | |
13 #include "xfa/fwl/core/fwl_noteimp.h" | |
14 #include "xfa/fwl/core/ifwl_app.h" | |
15 #include "xfa/fwl/core/ifwl_themeprovider.h" | |
16 | |
17 #define FWL_WGT_CalcHeight 2048 | |
18 #define FWL_WGT_CalcWidth 2048 | |
19 #define FWL_WGT_CalcMultiLineDefWidth 120.0f | |
20 | |
21 CFWL_Widget::CFWL_Widget() | |
22 : m_pDelegate(nullptr), | |
23 m_pWidgetMgr(CFWL_WidgetMgr::GetInstance()), | |
24 m_pProperties(new CFWL_WidgetProperties) { | |
25 ASSERT(m_pWidgetMgr); | |
26 } | |
27 | |
28 CFWL_Widget::~CFWL_Widget() { | |
29 if (m_pIface) | |
30 m_pIface->Finalize(); | |
31 } | |
32 | |
33 IFWL_Widget* CFWL_Widget::GetWidget() { | |
34 return m_pIface.get(); | |
35 } | |
36 | |
37 const IFWL_Widget* CFWL_Widget::GetWidget() const { | |
38 return m_pIface.get(); | |
39 } | |
40 | |
41 FWL_Error CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) { | |
42 if (!m_pIface) | |
43 return FWL_Error::Indefinite; | |
44 m_pIface->SetAssociateWidget(this); | |
45 return FWL_Error::Succeeded; | |
46 } | |
47 | |
48 FWL_Error CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | |
49 if (!m_pIface) | |
50 return FWL_Error::Indefinite; | |
51 return m_pIface->GetWidgetRect(rect, bAutoSize); | |
52 } | |
53 | |
54 FWL_Error CFWL_Widget::GetGlobalRect(CFX_RectF& rect) { | |
55 if (!m_pIface) | |
56 return FWL_Error::Indefinite; | |
57 return m_pIface->GetGlobalRect(rect); | |
58 } | |
59 | |
60 FWL_Error CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { | |
61 if (!m_pIface) | |
62 return FWL_Error::Indefinite; | |
63 return m_pIface->SetWidgetRect(rect); | |
64 } | |
65 | |
66 FWL_Error CFWL_Widget::GetClientRect(CFX_RectF& rect) { | |
67 if (!m_pIface) | |
68 return FWL_Error::Indefinite; | |
69 return m_pIface->GetClientRect(rect); | |
70 } | |
71 | |
72 FWL_Error CFWL_Widget::ModifyStyles(uint32_t dwStylesAdded, | |
73 uint32_t dwStylesRemoved) { | |
74 if (!m_pIface) | |
75 return FWL_Error::Indefinite; | |
76 return m_pIface->ModifyStyles(dwStylesAdded, dwStylesRemoved); | |
77 } | |
78 | |
79 uint32_t CFWL_Widget::GetStylesEx() { | |
80 if (!m_pIface) | |
81 return 0; | |
82 return m_pIface->GetStylesEx(); | |
83 } | |
84 | |
85 FWL_Error CFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded, | |
86 uint32_t dwStylesExRemoved) { | |
87 return m_pIface->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | |
88 } | |
89 | |
90 uint32_t CFWL_Widget::GetStates() { | |
91 return m_pIface ? m_pIface->GetStates() : 0; | |
92 } | |
93 | |
94 void CFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) { | |
95 if (m_pIface) | |
96 m_pIface->SetStates(dwStates, bSet); | |
97 } | |
98 | |
99 void CFWL_Widget::SetLayoutItem(void* pItem) { | |
100 if (m_pIface) | |
101 m_pIface->SetLayoutItem(pItem); | |
102 } | |
103 | |
104 void CFWL_Widget::Update() { | |
105 if (!m_pIface) | |
106 return; | |
107 m_pIface->Update(); | |
108 } | |
109 | |
110 void CFWL_Widget::LockUpdate() { | |
111 if (!m_pIface) | |
112 return; | |
113 m_pIface->LockUpdate(); | |
114 } | |
115 | |
116 void CFWL_Widget::UnlockUpdate() { | |
117 if (!m_pIface) | |
118 return; | |
119 m_pIface->UnlockUpdate(); | |
120 } | |
121 | |
122 FWL_WidgetHit CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | |
123 if (!m_pIface) | |
124 return FWL_WidgetHit::Unknown; | |
125 return m_pIface->HitTest(fx, fy); | |
126 } | |
127 | |
128 FWL_Error CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics, | |
129 const CFX_Matrix* pMatrix) { | |
130 if (!m_pIface) | |
131 return FWL_Error::Indefinite; | |
132 return m_pIface->DrawWidget(pGraphics, pMatrix); | |
133 } | |
134 | |
135 IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { | |
136 if (!m_pIface) | |
137 return nullptr; | |
138 | |
139 m_pDelegate = m_pIface->SetDelegate(pDelegate); | |
140 return m_pDelegate; | |
141 } | |
OLD | NEW |