OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fwl/lightwidget/cfwl_widget.h" | 7 #include "xfa/fwl/lightwidget/cfwl_widget.h" |
8 | 8 |
9 #include "xfa/fde/tto/fde_textout.h" | 9 #include "xfa/fde/tto/fde_textout.h" |
10 #include "xfa/fwl/core/cfwl_themetext.h" | 10 #include "xfa/fwl/core/cfwl_themetext.h" |
11 #include "xfa/fwl/core/fwl_noteimp.h" | 11 #include "xfa/fwl/core/fwl_noteimp.h" |
12 #include "xfa/fwl/core/fwl_noteimp.h" | 12 #include "xfa/fwl/core/fwl_noteimp.h" |
13 #include "xfa/fwl/core/fwl_targetimp.h" | |
14 #include "xfa/fwl/core/fwl_widgetimp.h" | 13 #include "xfa/fwl/core/fwl_widgetimp.h" |
15 #include "xfa/fwl/core/fwl_widgetmgrimp.h" | 14 #include "xfa/fwl/core/fwl_widgetmgrimp.h" |
| 15 #include "xfa/fwl/core/ifwl_app.h" |
16 #include "xfa/fwl/core/ifwl_themeprovider.h" | 16 #include "xfa/fwl/core/ifwl_themeprovider.h" |
17 #include "xfa/fwl/core/ifwl_thread.h" | |
18 | 17 |
19 IFWL_Widget* CFWL_Widget::GetWidget() { | 18 IFWL_Widget* CFWL_Widget::GetWidget() { |
20 return m_pIface; | 19 return m_pIface; |
21 } | 20 } |
22 | 21 |
23 FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const { | 22 FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const { |
24 if (!m_pIface) | 23 if (!m_pIface) |
25 return FWL_ERR_Indefinite; | 24 return FWL_ERR_Indefinite; |
26 return m_pIface->GetClassName(wsClass); | 25 return m_pIface->GetClassName(wsClass); |
27 } | 26 } |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } else { | 234 } else { |
236 m_pIface->GetWidgetRect(rect); | 235 m_pIface->GetWidgetRect(rect); |
237 rect.left = rect.top = 0; | 236 rect.left = rect.top = 0; |
238 } | 237 } |
239 return m_pWidgetMgr->RepaintWidget(m_pIface, &rect); | 238 return m_pWidgetMgr->RepaintWidget(m_pIface, &rect); |
240 } | 239 } |
241 | 240 |
242 FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus) { | 241 FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus) { |
243 if (!m_pIface) | 242 if (!m_pIface) |
244 return FWL_ERR_Indefinite; | 243 return FWL_ERR_Indefinite; |
245 IFWL_Thread* pThread = m_pIface->GetOwnerThread(); | 244 IFWL_App* pThread = m_pIface->GetOwnerThread(); |
246 if (!pThread) | 245 if (!pThread) |
247 return FWL_ERR_Indefinite; | 246 return FWL_ERR_Indefinite; |
248 IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); | 247 CFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); |
249 if (!pDriver) | 248 if (!pDriver) |
250 return FWL_ERR_Indefinite; | 249 return FWL_ERR_Indefinite; |
251 if (bFocus) { | 250 if (bFocus) { |
252 pDriver->SetFocus(m_pIface); | 251 pDriver->SetFocus(m_pIface); |
253 } else { | 252 } else { |
254 if (pDriver->GetFocus() == m_pIface) { | 253 if (pDriver->GetFocus() == m_pIface) { |
255 pDriver->SetFocus(NULL); | 254 pDriver->SetFocus(NULL); |
256 } | 255 } |
257 } | 256 } |
258 return FWL_ERR_Succeeded; | 257 return FWL_ERR_Succeeded; |
259 } | 258 } |
260 | 259 |
261 FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet) { | 260 FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet) { |
262 if (!m_pIface) | 261 if (!m_pIface) |
263 return FWL_ERR_Indefinite; | 262 return FWL_ERR_Indefinite; |
264 IFWL_Thread* pThread = m_pIface->GetOwnerThread(); | 263 IFWL_App* pThread = m_pIface->GetOwnerThread(); |
265 if (!pThread) | 264 if (!pThread) |
266 return FWL_ERR_Indefinite; | 265 return FWL_ERR_Indefinite; |
267 IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); | 266 CFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); |
268 if (!pDriver) | 267 if (!pDriver) |
269 return FWL_ERR_Indefinite; | 268 return FWL_ERR_Indefinite; |
270 pDriver->SetGrab(m_pIface, bSet); | 269 pDriver->SetGrab(m_pIface, bSet); |
271 return FWL_ERR_Succeeded; | 270 return FWL_ERR_Succeeded; |
272 } | 271 } |
273 | 272 |
274 void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource, | 273 void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource, |
275 uint32_t dwFilter) { | 274 uint32_t dwFilter) { |
276 if (!m_pIface) | 275 if (!m_pIface) |
277 return; | 276 return; |
278 IFWL_Thread* pThread = m_pIface->GetOwnerThread(); | 277 IFWL_App* pThread = m_pIface->GetOwnerThread(); |
279 if (!pThread) | 278 if (!pThread) |
280 return; | 279 return; |
281 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); | 280 CFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); |
282 if (!pNoteDriver) | 281 if (!pNoteDriver) |
283 return; | 282 return; |
284 IFWL_Widget* pEventSourceImp = | 283 IFWL_Widget* pEventSourceImp = |
285 !pEventSource ? NULL : pEventSource->GetWidget(); | 284 !pEventSource ? NULL : pEventSource->GetWidget(); |
286 pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter); | 285 pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter); |
287 } | 286 } |
288 | 287 |
289 void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { | 288 void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { |
290 if (!m_pIface) | 289 if (!m_pIface) |
291 return; | 290 return; |
292 if (m_pIface->GetOuter()) { | 291 if (m_pIface->GetOuter()) { |
293 return; | 292 return; |
294 } | 293 } |
295 IFWL_Thread* pThread = m_pIface->GetOwnerThread(); | 294 IFWL_App* pThread = m_pIface->GetOwnerThread(); |
296 if (!pThread) | 295 if (!pThread) |
297 return; | 296 return; |
298 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); | 297 CFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); |
299 if (!pNoteDriver) | 298 if (!pNoteDriver) |
300 return; | 299 return; |
301 pNoteDriver->SendEvent(pEvent); | 300 pNoteDriver->SendEvent(pEvent); |
302 } | 301 } |
303 | 302 |
304 #define FWL_WGT_CalcHeight 2048 | 303 #define FWL_WGT_CalcHeight 2048 |
305 #define FWL_WGT_CalcWidth 2048 | 304 #define FWL_WGT_CalcWidth 2048 |
306 #define FWL_WGT_CalcMultiLineDefWidth 120.0f | 305 #define FWL_WGT_CalcMultiLineDefWidth 120.0f |
307 | 306 |
308 CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText, | 307 CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText, |
(...skipping 13 matching lines...) Expand all Loading... |
322 calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; | 321 calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; |
323 CFX_RectF rect; | 322 CFX_RectF rect; |
324 FX_FLOAT fWidth = bMultiLine | 323 FX_FLOAT fWidth = bMultiLine |
325 ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth | 324 ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth |
326 : FWL_WGT_CalcMultiLineDefWidth) | 325 : FWL_WGT_CalcMultiLineDefWidth) |
327 : FWL_WGT_CalcWidth; | 326 : FWL_WGT_CalcWidth; |
328 rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); | 327 rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); |
329 pTheme->CalcTextRect(&calPart, rect); | 328 pTheme->CalcTextRect(&calPart, rect); |
330 return CFX_SizeF(rect.width, rect.height); | 329 return CFX_SizeF(rect.width, rect.height); |
331 } | 330 } |
OLD | NEW |