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" | 13 #include "xfa/fwl/core/fwl_targetimp.h" |
14 #include "xfa/fwl/core/fwl_widgetimp.h" | 14 #include "xfa/fwl/core/fwl_widgetimp.h" |
15 #include "xfa/fwl/core/fwl_widgetmgrimp.h" | 15 #include "xfa/fwl/core/fwl_widgetmgrimp.h" |
16 #include "xfa/fwl/core/ifwl_notethread.h" | |
17 #include "xfa/fwl/core/ifwl_themeprovider.h" | 16 #include "xfa/fwl/core/ifwl_themeprovider.h" |
| 17 #include "xfa/fwl/core/ifwl_thread.h" |
18 | 18 |
19 IFWL_Widget* CFWL_Widget::GetWidget() { | 19 IFWL_Widget* CFWL_Widget::GetWidget() { |
20 return m_pIface; | 20 return m_pIface; |
21 } | 21 } |
22 | 22 |
23 FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const { | 23 FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const { |
24 if (!m_pIface) | 24 if (!m_pIface) |
25 return FWL_ERR_Indefinite; | 25 return FWL_ERR_Indefinite; |
26 return m_pIface->GetClassName(wsClass); | 26 return m_pIface->GetClassName(wsClass); |
27 } | 27 } |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } else { | 235 } else { |
236 m_pIface->GetWidgetRect(rect); | 236 m_pIface->GetWidgetRect(rect); |
237 rect.left = rect.top = 0; | 237 rect.left = rect.top = 0; |
238 } | 238 } |
239 return m_pWidgetMgr->RepaintWidget(m_pIface, &rect); | 239 return m_pWidgetMgr->RepaintWidget(m_pIface, &rect); |
240 } | 240 } |
241 | 241 |
242 FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus) { | 242 FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus) { |
243 if (!m_pIface) | 243 if (!m_pIface) |
244 return FWL_ERR_Indefinite; | 244 return FWL_ERR_Indefinite; |
245 IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); | 245 IFWL_Thread* pThread = m_pIface->GetOwnerThread(); |
246 if (!pThread) | 246 if (!pThread) |
247 return FWL_ERR_Indefinite; | 247 return FWL_ERR_Indefinite; |
248 IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); | 248 IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); |
249 if (!pDriver) | 249 if (!pDriver) |
250 return FWL_ERR_Indefinite; | 250 return FWL_ERR_Indefinite; |
251 if (bFocus) { | 251 if (bFocus) { |
252 pDriver->SetFocus(m_pIface); | 252 pDriver->SetFocus(m_pIface); |
253 } else { | 253 } else { |
254 if (pDriver->GetFocus() == m_pIface) { | 254 if (pDriver->GetFocus() == m_pIface) { |
255 pDriver->SetFocus(NULL); | 255 pDriver->SetFocus(NULL); |
256 } | 256 } |
257 } | 257 } |
258 return FWL_ERR_Succeeded; | 258 return FWL_ERR_Succeeded; |
259 } | 259 } |
260 | 260 |
261 FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet) { | 261 FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet) { |
262 if (!m_pIface) | 262 if (!m_pIface) |
263 return FWL_ERR_Indefinite; | 263 return FWL_ERR_Indefinite; |
264 IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); | 264 IFWL_Thread* pThread = m_pIface->GetOwnerThread(); |
265 if (!pThread) | 265 if (!pThread) |
266 return FWL_ERR_Indefinite; | 266 return FWL_ERR_Indefinite; |
267 IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); | 267 IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); |
268 if (!pDriver) | 268 if (!pDriver) |
269 return FWL_ERR_Indefinite; | 269 return FWL_ERR_Indefinite; |
270 pDriver->SetGrab(m_pIface, bSet); | 270 pDriver->SetGrab(m_pIface, bSet); |
271 return FWL_ERR_Succeeded; | 271 return FWL_ERR_Succeeded; |
272 } | 272 } |
273 | 273 |
274 void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource, | 274 void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource, |
275 uint32_t dwFilter) { | 275 uint32_t dwFilter) { |
276 if (!m_pIface) | 276 if (!m_pIface) |
277 return; | 277 return; |
278 IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); | 278 IFWL_Thread* pThread = m_pIface->GetOwnerThread(); |
279 if (!pThread) | 279 if (!pThread) |
280 return; | 280 return; |
281 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); | 281 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); |
282 if (!pNoteDriver) | 282 if (!pNoteDriver) |
283 return; | 283 return; |
284 IFWL_Widget* pEventSourceImp = | 284 IFWL_Widget* pEventSourceImp = |
285 !pEventSource ? NULL : pEventSource->GetWidget(); | 285 !pEventSource ? NULL : pEventSource->GetWidget(); |
286 pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter); | 286 pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter); |
287 } | 287 } |
288 | 288 |
289 void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { | 289 void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { |
290 if (!m_pIface) | 290 if (!m_pIface) |
291 return; | 291 return; |
292 if (m_pIface->GetOuter()) { | 292 if (m_pIface->GetOuter()) { |
293 return; | 293 return; |
294 } | 294 } |
295 IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); | 295 IFWL_Thread* pThread = m_pIface->GetOwnerThread(); |
296 if (!pThread) | 296 if (!pThread) |
297 return; | 297 return; |
298 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); | 298 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); |
299 if (!pNoteDriver) | 299 if (!pNoteDriver) |
300 return; | 300 return; |
301 pNoteDriver->SendNote(pEvent); | 301 pNoteDriver->SendNote(pEvent); |
302 } | 302 } |
303 | 303 |
304 #define FWL_WGT_CalcHeight 2048 | 304 #define FWL_WGT_CalcHeight 2048 |
305 #define FWL_WGT_CalcWidth 2048 | 305 #define FWL_WGT_CalcWidth 2048 |
(...skipping 16 matching lines...) Expand all Loading... |
322 calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; | 322 calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; |
323 CFX_RectF rect; | 323 CFX_RectF rect; |
324 FX_FLOAT fWidth = bMultiLine | 324 FX_FLOAT fWidth = bMultiLine |
325 ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth | 325 ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth |
326 : FWL_WGT_CalcMultiLineDefWidth) | 326 : FWL_WGT_CalcMultiLineDefWidth) |
327 : FWL_WGT_CalcWidth; | 327 : FWL_WGT_CalcWidth; |
328 rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); | 328 rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); |
329 pTheme->CalcTextRect(&calPart, rect); | 329 pTheme->CalcTextRect(&calPart, rect); |
330 return CFX_SizeF(rect.width, rect.height); | 330 return CFX_SizeF(rect.width, rect.height); |
331 } | 331 } |
OLD | NEW |