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/core/cfwl_widget.h" | 7 #include "xfa/fwl/core/cfwl_widget.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 if (!bAutoSize) { | 69 if (!bAutoSize) { |
70 rect = m_pProperties->m_rtWidget; | 70 rect = m_pProperties->m_rtWidget; |
71 return; | 71 return; |
72 } | 72 } |
73 | 73 |
74 if (HasEdge()) { | 74 if (HasEdge()) { |
75 FX_FLOAT fEdge = GetEdgeWidth(); | 75 FX_FLOAT fEdge = GetEdgeWidth(); |
76 rect.Inflate(fEdge, fEdge); | 76 rect.Inflate(fEdge, fEdge); |
77 } | 77 } |
78 if (HasBorder()) { | 78 if (HasBorder()) { |
79 FX_FLOAT fBorder = GetBorderSize(); | 79 FX_FLOAT fBorder = GetBorderSize(true); |
80 rect.Inflate(fBorder, fBorder); | 80 rect.Inflate(fBorder, fBorder); |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 void CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { | 84 void CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { |
85 m_pProperties->m_rtWidget = rect; | 85 m_pProperties->m_rtWidget = rect; |
86 if (IsChild()) | 86 if (IsChild()) |
87 return; | 87 return; |
88 | 88 |
89 m_pWidgetMgr->SetWidgetRect_Native(this, rect); | 89 m_pWidgetMgr->SetWidgetRect_Native(this, rect); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 } | 310 } |
311 | 311 |
312 bool CFWL_Widget::IsOffscreen() const { | 312 bool CFWL_Widget::IsOffscreen() const { |
313 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Offscreen); | 313 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Offscreen); |
314 } | 314 } |
315 | 315 |
316 void CFWL_Widget::GetEdgeRect(CFX_RectF& rtEdge) { | 316 void CFWL_Widget::GetEdgeRect(CFX_RectF& rtEdge) { |
317 rtEdge = m_pProperties->m_rtWidget; | 317 rtEdge = m_pProperties->m_rtWidget; |
318 rtEdge.left = rtEdge.top = 0; | 318 rtEdge.left = rtEdge.top = 0; |
319 if (HasBorder()) { | 319 if (HasBorder()) { |
320 FX_FLOAT fCX = GetBorderSize(); | 320 FX_FLOAT fCX = GetBorderSize(true); |
321 FX_FLOAT fCY = GetBorderSize(false); | 321 FX_FLOAT fCY = GetBorderSize(false); |
322 rtEdge.Deflate(fCX, fCY); | 322 rtEdge.Deflate(fCX, fCY); |
323 } | 323 } |
324 } | 324 } |
325 | 325 |
326 FX_FLOAT CFWL_Widget::GetBorderSize(bool bCX) { | 326 FX_FLOAT CFWL_Widget::GetBorderSize(bool bCX) { |
327 FX_FLOAT* pfBorder = static_cast<FX_FLOAT*>(GetThemeCapacity( | 327 FX_FLOAT* pfBorder = static_cast<FX_FLOAT*>(GetThemeCapacity( |
328 bCX ? CFWL_WidgetCapacity::CXBorder : CFWL_WidgetCapacity::CYBorder)); | 328 bCX ? CFWL_WidgetCapacity::CXBorder : CFWL_WidgetCapacity::CYBorder)); |
329 if (!pfBorder) | 329 if (!pfBorder) |
330 return 0; | 330 return 0; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 if (!pRet) | 392 if (!pRet) |
393 return nullptr; | 393 return nullptr; |
394 | 394 |
395 while (CFWL_Widget* pOuter = pRet->GetOuter()) | 395 while (CFWL_Widget* pOuter = pRet->GetOuter()) |
396 pRet = pOuter; | 396 pRet = pOuter; |
397 return pRet; | 397 return pRet; |
398 } | 398 } |
399 | 399 |
400 CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText, | 400 CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText, |
401 IFWL_ThemeProvider* pTheme, | 401 IFWL_ThemeProvider* pTheme, |
402 bool bMultiLine, | 402 bool bMultiLine) { |
403 int32_t iLineWidth) { | |
404 if (!pTheme) | 403 if (!pTheme) |
405 return CFX_SizeF(); | 404 return CFX_SizeF(); |
406 | 405 |
407 CFWL_ThemeText calPart; | 406 CFWL_ThemeText calPart; |
408 calPart.m_pWidget = this; | 407 calPart.m_pWidget = this; |
409 calPart.m_wsText = wsText; | 408 calPart.m_wsText = wsText; |
410 calPart.m_dwTTOStyles = | 409 calPart.m_dwTTOStyles = |
411 bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine; | 410 bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine; |
412 calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; | 411 calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; |
413 CFX_RectF rect; | 412 CFX_RectF rect; |
414 FX_FLOAT fWidth = bMultiLine | 413 FX_FLOAT fWidth = |
415 ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth | 414 bMultiLine ? FWL_WGT_CalcMultiLineDefWidth : FWL_WGT_CalcWidth; |
416 : FWL_WGT_CalcMultiLineDefWidth) | |
417 : FWL_WGT_CalcWidth; | |
418 rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); | 415 rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); |
419 pTheme->CalcTextRect(&calPart, rect); | 416 pTheme->CalcTextRect(&calPart, rect); |
420 return CFX_SizeF(rect.width, rect.height); | 417 return CFX_SizeF(rect.width, rect.height); |
421 } | 418 } |
422 | 419 |
423 void CFWL_Widget::CalcTextRect(const CFX_WideString& wsText, | 420 void CFWL_Widget::CalcTextRect(const CFX_WideString& wsText, |
424 IFWL_ThemeProvider* pTheme, | 421 IFWL_ThemeProvider* pTheme, |
425 uint32_t dwTTOStyles, | 422 uint32_t dwTTOStyles, |
426 int32_t iTTOAlign, | 423 int32_t iTTOAlign, |
427 CFX_RectF& rect) { | 424 CFX_RectF& rect) { |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 } | 717 } |
721 default: | 718 default: |
722 break; | 719 break; |
723 } | 720 } |
724 } | 721 } |
725 | 722 |
726 void CFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {} | 723 void CFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {} |
727 | 724 |
728 void CFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics, | 725 void CFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics, |
729 const CFX_Matrix* pMatrix) {} | 726 const CFX_Matrix* pMatrix) {} |
OLD | NEW |