| 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_checkbox.h" | 7 #include "xfa/fwl/core/ifwl_checkbox.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 if (!bAutoSize) { | 50 if (!bAutoSize) { |
| 51 rect = m_pProperties->m_rtWidget; | 51 rect = m_pProperties->m_rtWidget; |
| 52 return; | 52 return; |
| 53 } | 53 } |
| 54 | 54 |
| 55 rect.Set(0, 0, 0, 0); | 55 rect.Set(0, 0, 0, 0); |
| 56 if (!m_pProperties->m_pThemeProvider) | 56 if (!m_pProperties->m_pThemeProvider) |
| 57 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 57 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 58 if (!m_pProperties->m_pThemeProvider) | 58 if (!m_pProperties->m_pThemeProvider) |
| 59 return; | 59 return; |
| 60 if (!m_pProperties->m_pDataProvider) | |
| 61 return; | |
| 62 | 60 |
| 63 CFX_SizeF sz = CalcTextSize( | 61 CFX_SizeF sz = CalcTextSize( |
| 64 L"Check box", m_pProperties->m_pThemeProvider, | 62 L"Check box", m_pProperties->m_pThemeProvider, |
| 65 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine)); | 63 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine)); |
| 66 rect.Set(0, 0, sz.x, sz.y); | 64 rect.Set(0, 0, sz.x, sz.y); |
| 67 rect.Inflate(kCaptionMargin, kCaptionMargin); | 65 rect.Inflate(kCaptionMargin, kCaptionMargin); |
| 68 | 66 |
| 69 IFWL_CheckBox::DataProvider* pData = | 67 FX_FLOAT fCheckBox = m_pDataProvider->GetBoxSize(this); |
| 70 static_cast<IFWL_CheckBox::DataProvider*>(m_pProperties->m_pDataProvider); | |
| 71 FX_FLOAT fCheckBox = pData->GetBoxSize(this); | |
| 72 rect.width += fCheckBox; | 68 rect.width += fCheckBox; |
| 73 rect.height = std::max(rect.height, fCheckBox); | 69 rect.height = std::max(rect.height, fCheckBox); |
| 74 IFWL_Widget::GetWidgetRect(rect, true); | 70 IFWL_Widget::GetWidgetRect(rect, true); |
| 75 } | 71 } |
| 76 | 72 |
| 77 void IFWL_CheckBox::Update() { | 73 void IFWL_CheckBox::Update() { |
| 78 if (IsLocked()) | 74 if (IsLocked()) |
| 79 return; | 75 return; |
| 80 if (!m_pProperties->m_pThemeProvider) | 76 if (!m_pProperties->m_pThemeProvider) |
| 81 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 77 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 110 param.m_matrix.Concat(*pMatrix); | 106 param.m_matrix.Concat(*pMatrix); |
| 111 param.m_rtPart = m_rtClient; | 107 param.m_rtPart = m_rtClient; |
| 112 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) | 108 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) |
| 113 param.m_pData = &m_rtFocus; | 109 param.m_pData = &m_rtFocus; |
| 114 pTheme->DrawBackground(¶m); | 110 pTheme->DrawBackground(¶m); |
| 115 | 111 |
| 116 param.m_iPart = CFWL_Part::CheckBox; | 112 param.m_iPart = CFWL_Part::CheckBox; |
| 117 param.m_rtPart = m_rtBox; | 113 param.m_rtPart = m_rtBox; |
| 118 pTheme->DrawBackground(¶m); | 114 pTheme->DrawBackground(¶m); |
| 119 | 115 |
| 120 if (!m_pProperties->m_pDataProvider) | |
| 121 return; | |
| 122 | |
| 123 CFWL_ThemeText textParam; | 116 CFWL_ThemeText textParam; |
| 124 textParam.m_pWidget = this; | 117 textParam.m_pWidget = this; |
| 125 textParam.m_iPart = CFWL_Part::Caption; | 118 textParam.m_iPart = CFWL_Part::Caption; |
| 126 textParam.m_dwStates = dwStates; | 119 textParam.m_dwStates = dwStates; |
| 127 textParam.m_pGraphics = pGraphics; | 120 textParam.m_pGraphics = pGraphics; |
| 128 if (pMatrix) | 121 if (pMatrix) |
| 129 textParam.m_matrix.Concat(*pMatrix); | 122 textParam.m_matrix.Concat(*pMatrix); |
| 130 textParam.m_rtPart = m_rtCaption; | 123 textParam.m_rtPart = m_rtCaption; |
| 131 textParam.m_wsText = L"Check box"; | 124 textParam.m_wsText = L"Check box"; |
| 132 textParam.m_dwTTOStyles = m_dwTTOStyles; | 125 textParam.m_dwTTOStyles = m_dwTTOStyles; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 150 Repaint(&m_rtClient); | 143 Repaint(&m_rtClient); |
| 151 } | 144 } |
| 152 | 145 |
| 153 void IFWL_CheckBox::Layout() { | 146 void IFWL_CheckBox::Layout() { |
| 154 m_pProperties->m_rtWidget.width = | 147 m_pProperties->m_rtWidget.width = |
| 155 FXSYS_round(m_pProperties->m_rtWidget.width); | 148 FXSYS_round(m_pProperties->m_rtWidget.width); |
| 156 m_pProperties->m_rtWidget.height = | 149 m_pProperties->m_rtWidget.height = |
| 157 FXSYS_round(m_pProperties->m_rtWidget.height); | 150 FXSYS_round(m_pProperties->m_rtWidget.height); |
| 158 GetClientRect(m_rtClient); | 151 GetClientRect(m_rtClient); |
| 159 | 152 |
| 160 if (!m_pProperties->m_pDataProvider) | |
| 161 return; | |
| 162 | |
| 163 FX_FLOAT fBoxTop = m_rtClient.top; | 153 FX_FLOAT fBoxTop = m_rtClient.top; |
| 164 FX_FLOAT fClientBottom = m_rtClient.bottom(); | 154 FX_FLOAT fClientBottom = m_rtClient.bottom(); |
| 165 | 155 |
| 166 IFWL_CheckBox::DataProvider* pData = | 156 FX_FLOAT fCheckBox = m_pDataProvider->GetBoxSize(this); |
| 167 static_cast<IFWL_CheckBox::DataProvider*>(m_pProperties->m_pDataProvider); | |
| 168 FX_FLOAT fCheckBox = pData->GetBoxSize(this); | |
| 169 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) { | 157 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) { |
| 170 case FWL_STYLEEXT_CKB_Top: | 158 case FWL_STYLEEXT_CKB_Top: |
| 171 break; | 159 break; |
| 172 case FWL_STYLEEXT_CKB_Bottom: { | 160 case FWL_STYLEEXT_CKB_Bottom: { |
| 173 fBoxTop = fClientBottom - fCheckBox; | 161 fBoxTop = fClientBottom - fCheckBox; |
| 174 break; | 162 break; |
| 175 } | 163 } |
| 176 case FWL_STYLEEXT_CKB_VCenter: | 164 case FWL_STYLEEXT_CKB_VCenter: |
| 177 default: { | 165 default: { |
| 178 fBoxTop = m_rtClient.top + (m_rtClient.height - fCheckBox) / 2; | 166 fBoxTop = m_rtClient.top + (m_rtClient.height - fCheckBox) / 2; |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 void IFWL_CheckBox::OnKeyDown(CFWL_MsgKey* pMsg) { | 474 void IFWL_CheckBox::OnKeyDown(CFWL_MsgKey* pMsg) { |
| 487 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { | 475 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { |
| 488 DispatchKeyEvent(pMsg); | 476 DispatchKeyEvent(pMsg); |
| 489 return; | 477 return; |
| 490 } | 478 } |
| 491 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || | 479 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || |
| 492 pMsg->m_dwKeyCode == FWL_VKEY_Space) { | 480 pMsg->m_dwKeyCode == FWL_VKEY_Space) { |
| 493 NextStates(); | 481 NextStates(); |
| 494 } | 482 } |
| 495 } | 483 } |
| OLD | NEW |