| 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/ifwl_pushbutton.h" | 7 #include "xfa/fwl/core/ifwl_pushbutton.h" |
| 8 | 8 |
| 9 #include "third_party/base/ptr_util.h" | 9 #include "third_party/base/ptr_util.h" |
| 10 #include "xfa/fde/tto/fde_textout.h" | 10 #include "xfa/fde/tto/fde_textout.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 if (!bAutoSize) { | 39 if (!bAutoSize) { |
| 40 rect = m_pProperties->m_rtWidget; | 40 rect = m_pProperties->m_rtWidget; |
| 41 return; | 41 return; |
| 42 } | 42 } |
| 43 | 43 |
| 44 rect.Set(0, 0, 0, 0); | 44 rect.Set(0, 0, 0, 0); |
| 45 if (!m_pProperties->m_pThemeProvider) | 45 if (!m_pProperties->m_pThemeProvider) |
| 46 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 46 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 47 | 47 |
| 48 CFX_WideString wsCaption; | 48 CFX_WideString wsCaption; |
| 49 IFWL_PushButtonDP* pData = | 49 if (m_pProperties->m_pDataProvider) |
| 50 static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider); | 50 m_pProperties->m_pDataProvider->GetCaption(this, wsCaption); |
| 51 if (pData) | |
| 52 pData->GetCaption(this, wsCaption); | |
| 53 | 51 |
| 54 int32_t iLen = wsCaption.GetLength(); | 52 int32_t iLen = wsCaption.GetLength(); |
| 55 if (iLen > 0) { | 53 if (iLen > 0) { |
| 56 CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider); | 54 CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider); |
| 57 rect.Set(0, 0, sz.x, sz.y); | 55 rect.Set(0, 0, sz.x, sz.y); |
| 58 } | 56 } |
| 59 | 57 |
| 60 FX_FLOAT* fcaption = | 58 FX_FLOAT* fcaption = |
| 61 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin)); | 59 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin)); |
| 62 rect.Inflate(*fcaption, *fcaption); | 60 rect.Inflate(*fcaption, *fcaption); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 85 m_rtCaption.Inflate(-*fcaption, -*fcaption); | 83 m_rtCaption.Inflate(-*fcaption, -*fcaption); |
| 86 } | 84 } |
| 87 | 85 |
| 88 void IFWL_PushButton::DrawWidget(CFX_Graphics* pGraphics, | 86 void IFWL_PushButton::DrawWidget(CFX_Graphics* pGraphics, |
| 89 const CFX_Matrix* pMatrix) { | 87 const CFX_Matrix* pMatrix) { |
| 90 if (!pGraphics) | 88 if (!pGraphics) |
| 91 return; | 89 return; |
| 92 if (!m_pProperties->m_pThemeProvider) | 90 if (!m_pProperties->m_pThemeProvider) |
| 93 return; | 91 return; |
| 94 | 92 |
| 95 IFWL_PushButtonDP* pData = | |
| 96 static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider); | |
| 97 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 93 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
| 98 if (HasBorder()) { | 94 if (HasBorder()) { |
| 99 DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider, | 95 DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider, |
| 100 pMatrix); | 96 pMatrix); |
| 101 } | 97 } |
| 102 if (HasEdge()) { | 98 if (HasEdge()) { |
| 103 DrawEdge(pGraphics, CFWL_Part::Edge, m_pProperties->m_pThemeProvider, | 99 DrawEdge(pGraphics, CFWL_Part::Edge, m_pProperties->m_pThemeProvider, |
| 104 pMatrix); | 100 pMatrix); |
| 105 } | 101 } |
| 106 DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); | 102 DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); |
| 107 CFX_Matrix matrix; | 103 CFX_Matrix matrix; |
| 108 matrix.Concat(*pMatrix); | 104 matrix.Concat(*pMatrix); |
| 109 | 105 |
| 110 CFX_WideString wsCaption; | 106 CFX_WideString wsCaption; |
| 111 if (pData) | 107 if (m_pProperties->m_pDataProvider) |
| 112 pData->GetCaption(this, wsCaption); | 108 m_pProperties->m_pDataProvider->GetCaption(this, wsCaption); |
| 113 | 109 |
| 114 CFX_RectF rtText; | 110 CFX_RectF rtText; |
| 115 rtText.Set(0, 0, 0, 0); | 111 rtText.Set(0, 0, 0, 0); |
| 116 if (!wsCaption.IsEmpty()) | 112 if (!wsCaption.IsEmpty()) |
| 117 CalcTextRect(wsCaption, pTheme, 0, m_iTTOAlign, rtText); | 113 CalcTextRect(wsCaption, pTheme, 0, m_iTTOAlign, rtText); |
| 118 | 114 |
| 119 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_PSB_ModeMask) { | 115 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_PSB_ModeMask) { |
| 120 case FWL_STYLEEXT_PSB_TextOnly: | 116 case FWL_STYLEEXT_PSB_TextOnly: |
| 121 DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix); | 117 DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix); |
| 122 break; | 118 break; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 CFWL_EvtClick wmClick; | 361 CFWL_EvtClick wmClick; |
| 366 wmClick.m_pSrcTarget = this; | 362 wmClick.m_pSrcTarget = this; |
| 367 DispatchEvent(&wmClick); | 363 DispatchEvent(&wmClick); |
| 368 return; | 364 return; |
| 369 } | 365 } |
| 370 if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) | 366 if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) |
| 371 return; | 367 return; |
| 372 | 368 |
| 373 DispatchKeyEvent(pMsg); | 369 DispatchKeyEvent(pMsg); |
| 374 } | 370 } |
| OLD | NEW |