Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: xfa/src/fwl/lightwidget/widget.cpp

Issue 1803723002: Move xfa/src up to xfa/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/src/fwl/lightwidget/tooltipctrl.cpp ('k') | xfa/src/fwl/theme/barcodetp.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/lightwidget/widget.h"
8
9 #include "xfa/include/fwl/core/fwl_theme.h"
10 #include "xfa/include/fwl/core/fwl_thread.h"
11 #include "xfa/src/fde/tto/fde_textout.h"
12 #include "xfa/src/fwl/core/fwl_noteimp.h"
13 #include "xfa/src/fwl/core/fwl_noteimp.h"
14 #include "xfa/src/fwl/core/fwl_targetimp.h"
15 #include "xfa/src/fwl/core/fwl_widgetimp.h"
16 #include "xfa/src/fwl/core/fwl_widgetmgrimp.h"
17
18 CFWL_WidgetImpProperties CFWL_WidgetProperties::MakeWidgetImpProperties(
19 IFWL_DataProvider* pDataProvider) const {
20 CFWL_WidgetImpProperties result;
21 result.m_ctmOnParent = m_ctmOnParent;
22 result.m_rtWidget = m_rtWidget;
23 result.m_dwStyles = m_dwStyles;
24 result.m_dwStyleExes = m_dwStyleExes;
25 result.m_dwStates = m_dwStates;
26 if (m_pParent)
27 result.m_pParent = m_pParent->GetWidget();
28 if (m_pOwner)
29 result.m_pOwner = m_pOwner->GetWidget();
30 result.m_pDataProvider = pDataProvider;
31 return result;
32 }
33 IFWL_Widget* CFWL_Widget::GetWidget() {
34 return m_pIface;
35 }
36 FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const {
37 if (!m_pIface)
38 return FWL_ERR_Indefinite;
39 return m_pIface->GetClassName(wsClass);
40 }
41 FX_DWORD CFWL_Widget::GetClassID() const {
42 if (!m_pIface)
43 return 0;
44 return m_pIface->GetClassID();
45 }
46 FX_BOOL CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const {
47 if (!m_pIface)
48 return FALSE;
49 return m_pIface->IsInstance(wsClass);
50 }
51 static void* gs_pFWLWidget = (void*)FXBSTR_ID('l', 'i', 'g', 't');
52 FWL_ERR CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) {
53 if (!m_pIface)
54 return FWL_ERR_Indefinite;
55 return m_pIface->SetPrivateData(gs_pFWLWidget, this, NULL);
56 }
57 FWL_ERR CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
58 if (!m_pIface)
59 return FWL_ERR_Indefinite;
60 return m_pIface->GetWidgetRect(rect, bAutoSize);
61 }
62 FWL_ERR CFWL_Widget::GetGlobalRect(CFX_RectF& rect) {
63 if (!m_pIface)
64 return FWL_ERR_Indefinite;
65 return m_pIface->GetGlobalRect(rect);
66 }
67 FWL_ERR CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) {
68 if (!m_pIface)
69 return FWL_ERR_Indefinite;
70 return m_pIface->SetWidgetRect(rect);
71 }
72 FWL_ERR CFWL_Widget::GetClientRect(CFX_RectF& rect) {
73 if (!m_pIface)
74 return FWL_ERR_Indefinite;
75 return m_pIface->GetClientRect(rect);
76 }
77 CFWL_Widget* CFWL_Widget::GetParent() {
78 if (!m_pIface)
79 return NULL;
80 IFWL_Widget* parent = m_pIface->GetParent();
81 if (parent) {
82 return static_cast<CFWL_Widget*>(parent->GetPrivateData(gs_pFWLWidget));
83 }
84 return NULL;
85 }
86 FWL_ERR CFWL_Widget::SetParent(CFWL_Widget* pParent) {
87 if (!m_pIface)
88 return FWL_ERR_Indefinite;
89 return m_pIface->SetParent(pParent ? pParent->GetWidget() : NULL);
90 }
91 CFWL_Widget* CFWL_Widget::GetOwner() {
92 if (!m_pIface)
93 return NULL;
94 return NULL;
95 }
96 FWL_ERR CFWL_Widget::SetOwner(CFWL_Widget* pOwner) {
97 if (!m_pIface)
98 return FWL_ERR_Indefinite;
99 return FWL_ERR_Succeeded;
100 }
101 FX_DWORD CFWL_Widget::GetStyles() {
102 if (!m_pIface)
103 return 0;
104 return m_pIface->GetStyles();
105 }
106 FWL_ERR CFWL_Widget::ModifyStyles(FX_DWORD dwStylesAdded,
107 FX_DWORD dwStylesRemoved) {
108 if (!m_pIface)
109 return FWL_ERR_Indefinite;
110 return m_pIface->ModifyStyles(dwStylesAdded, dwStylesRemoved);
111 }
112 FX_DWORD CFWL_Widget::GetStylesEx() {
113 if (!m_pIface)
114 return 0;
115 return m_pIface->GetStylesEx();
116 }
117 FWL_ERR CFWL_Widget::ModifyStylesEx(FX_DWORD dwStylesExAdded,
118 FX_DWORD dwStylesExRemoved) {
119 return m_pIface->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
120 }
121 FX_DWORD CFWL_Widget::GetStates() {
122 if (!m_pIface)
123 return FWL_ERR_Indefinite;
124 return m_pIface->GetStates();
125 }
126 FWL_ERR CFWL_Widget::SetStates(FX_DWORD dwStates, FX_BOOL bSet) {
127 if (!m_pIface)
128 return FWL_ERR_Indefinite;
129 return m_pIface->SetStates(dwStates, bSet);
130 }
131 FWL_ERR CFWL_Widget::SetPrivateData(void* module_id,
132 void* pData,
133 PD_CALLBACK_FREEDATA callback) {
134 if (!m_pIface)
135 return FWL_ERR_Indefinite;
136 return m_pIface->SetPrivateData(module_id, pData, callback);
137 }
138 void* CFWL_Widget::GetPrivateData(void* module_id) {
139 if (!m_pIface)
140 return NULL;
141 return m_pIface->GetPrivateData(module_id);
142 }
143 FWL_ERR CFWL_Widget::Update() {
144 if (!m_pIface)
145 return FWL_ERR_Indefinite;
146 return m_pIface->Update();
147 }
148 FWL_ERR CFWL_Widget::LockUpdate() {
149 if (!m_pIface)
150 return FWL_ERR_Indefinite;
151 return m_pIface->LockUpdate();
152 }
153 FWL_ERR CFWL_Widget::UnlockUpdate() {
154 if (!m_pIface)
155 return FWL_ERR_Indefinite;
156 return m_pIface->UnlockUpdate();
157 }
158 FX_DWORD CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
159 if (!m_pIface)
160 return 0;
161 return m_pIface->HitTest(fx, fy);
162 }
163 FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget,
164 FX_FLOAT& fx,
165 FX_FLOAT& fy) {
166 if (!m_pIface)
167 return FWL_ERR_Indefinite;
168 return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : NULL, fx, fy);
169 }
170 FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt) {
171 if (!m_pIface)
172 return FWL_ERR_Indefinite;
173 return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : NULL, rt);
174 }
175 FWL_ERR CFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) {
176 if (!m_pIface)
177 return FWL_ERR_Indefinite;
178 return m_pIface->GetMatrix(matrix, bGlobal);
179 }
180 FWL_ERR CFWL_Widget::SetMatrix(const CFX_Matrix& matrix) {
181 if (!m_pIface)
182 return FWL_ERR_Indefinite;
183 return m_pIface->SetMatrix(matrix);
184 }
185 FWL_ERR CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics,
186 const CFX_Matrix* pMatrix) {
187 if (!m_pIface)
188 return FWL_ERR_Indefinite;
189 return m_pIface->DrawWidget(pGraphics, pMatrix);
190 }
191 IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) {
192 if (!m_pIface)
193 return NULL;
194 m_pDelegate = m_pIface->SetDelegate(pDelegate);
195 return m_pDelegate;
196 }
197 CFWL_Widget::CFWL_Widget()
198 : m_pIface(NULL), m_pDelegate(NULL), m_pProperties(NULL) {
199 m_pProperties = new CFWL_WidgetProperties;
200 m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
201 FXSYS_assert(m_pWidgetMgr != NULL);
202 }
203 CFWL_Widget::~CFWL_Widget() {
204 delete m_pProperties;
205 if (m_pIface) {
206 m_pIface->Finalize();
207 delete m_pIface;
208 }
209 }
210 FWL_ERR CFWL_Widget::Repaint(const CFX_RectF* pRect) {
211 if (!m_pIface)
212 return FWL_ERR_Indefinite;
213 CFX_RectF rect;
214 if (pRect) {
215 rect = *pRect;
216 } else {
217 m_pIface->GetWidgetRect(rect);
218 rect.left = rect.top = 0;
219 }
220 return m_pWidgetMgr->RepaintWidget(m_pIface, &rect);
221 }
222 FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus) {
223 if (!m_pIface)
224 return FWL_ERR_Indefinite;
225 IFWL_NoteThread* pThread = m_pIface->GetOwnerThread();
226 if (!pThread)
227 return FWL_ERR_Indefinite;
228 IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
229 if (!pDriver)
230 return FWL_ERR_Indefinite;
231 if (bFocus) {
232 pDriver->SetFocus(m_pIface);
233 } else {
234 if (pDriver->GetFocus() == m_pIface) {
235 pDriver->SetFocus(NULL);
236 }
237 }
238 return FWL_ERR_Succeeded;
239 }
240 FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet) {
241 if (!m_pIface)
242 return FWL_ERR_Indefinite;
243 IFWL_NoteThread* pThread = m_pIface->GetOwnerThread();
244 if (!pThread)
245 return FWL_ERR_Indefinite;
246 IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
247 if (!pDriver)
248 return FWL_ERR_Indefinite;
249 pDriver->SetGrab(m_pIface, bSet);
250 return FWL_ERR_Succeeded;
251 }
252 void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource,
253 FX_DWORD dwFilter) {
254 if (!m_pIface)
255 return;
256 IFWL_NoteThread* pThread = m_pIface->GetOwnerThread();
257 if (!pThread)
258 return;
259 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
260 if (!pNoteDriver)
261 return;
262 IFWL_Widget* pEventSourceImp =
263 !pEventSource ? NULL : pEventSource->GetWidget();
264 pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter);
265 }
266 void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) {
267 if (!m_pIface)
268 return;
269 if (m_pIface->GetOuter()) {
270 return;
271 }
272 IFWL_NoteThread* pThread = m_pIface->GetOwnerThread();
273 if (!pThread)
274 return;
275 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
276 if (!pNoteDriver)
277 return;
278 pNoteDriver->SendNote(pEvent);
279 }
280 #define FWL_WGT_CalcHeight 2048
281 #define FWL_WGT_CalcWidth 2048
282 #define FWL_WGT_CalcMultiLineDefWidth 120.0f
283 CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText,
284 FX_BOOL bMultiLine,
285 int32_t iLineWidth) {
286 if (!m_pIface)
287 return CFX_SizeF();
288 IFWL_ThemeProvider* pTheme = m_pIface->GetThemeProvider();
289 if (!pTheme)
290 return CFX_SizeF();
291
292 CFWL_ThemeText calPart;
293 calPart.m_pWidget = m_pIface;
294 calPart.m_wsText = wsText;
295 calPart.m_dwTTOStyles =
296 bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine;
297 calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
298 CFX_RectF rect;
299 FX_FLOAT fWidth = bMultiLine
300 ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth
301 : FWL_WGT_CalcMultiLineDefWidth)
302 : FWL_WGT_CalcWidth;
303 rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight);
304 pTheme->CalcTextRect(&calPart, rect);
305 return CFX_SizeF(rect.width, rect.height);
306 }
307 CFWL_WidgetDelegate::CFWL_WidgetDelegate() {}
308 CFWL_WidgetDelegate::~CFWL_WidgetDelegate() {}
309 int32_t CFWL_WidgetDelegate::OnProcessMessage(CFWL_Message* pMessage) {
310 return 1;
311 }
312 FWL_ERR CFWL_WidgetDelegate::OnProcessEvent(CFWL_Event* pEvent) {
313 return FWL_ERR_Succeeded;
314 }
315 FWL_ERR CFWL_WidgetDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
316 const CFX_Matrix* pMatrix) {
317 return FWL_ERR_Succeeded;
318 }
OLDNEW
« no previous file with comments | « xfa/src/fwl/lightwidget/tooltipctrl.cpp ('k') | xfa/src/fwl/theme/barcodetp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698