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> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "third_party/base/ptr_util.h" | 13 #include "third_party/base/ptr_util.h" |
14 #include "xfa/fde/tto/fde_textout.h" | 14 #include "xfa/fde/tto/fde_textout.h" |
15 #include "xfa/fwl/core/cfwl_evtcheckstatechanged.h" | 15 #include "xfa/fwl/core/cfwl_evtcheckstatechanged.h" |
16 #include "xfa/fwl/core/cfwl_msgkey.h" | 16 #include "xfa/fwl/core/cfwl_msgkey.h" |
17 #include "xfa/fwl/core/cfwl_msgmouse.h" | 17 #include "xfa/fwl/core/cfwl_msgmouse.h" |
| 18 #include "xfa/fwl/core/cfwl_notedriver.h" |
18 #include "xfa/fwl/core/cfwl_themebackground.h" | 19 #include "xfa/fwl/core/cfwl_themebackground.h" |
19 #include "xfa/fwl/core/cfwl_themetext.h" | 20 #include "xfa/fwl/core/cfwl_themetext.h" |
20 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 21 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
21 #include "xfa/fwl/core/fwl_noteimp.h" | |
22 #include "xfa/fwl/core/ifwl_app.h" | 22 #include "xfa/fwl/core/ifwl_app.h" |
23 #include "xfa/fwl/core/ifwl_themeprovider.h" | 23 #include "xfa/fwl/core/ifwl_themeprovider.h" |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 const int kCaptionMargin = 5; | 27 const int kCaptionMargin = 5; |
28 | 28 |
29 } // namespace | 29 } // namespace |
30 | 30 |
31 IFWL_CheckBox::IFWL_CheckBox(const IFWL_App* app, | 31 IFWL_CheckBox::IFWL_CheckBox(const IFWL_App* app, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 CFX_WideString wsCaption; | 63 CFX_WideString wsCaption; |
64 m_pProperties->m_pDataProvider->GetCaption(this, wsCaption); | 64 m_pProperties->m_pDataProvider->GetCaption(this, wsCaption); |
65 if (wsCaption.GetLength() > 0) { | 65 if (wsCaption.GetLength() > 0) { |
66 CFX_SizeF sz = CalcTextSize( | 66 CFX_SizeF sz = CalcTextSize( |
67 wsCaption, m_pProperties->m_pThemeProvider, | 67 wsCaption, m_pProperties->m_pThemeProvider, |
68 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine)); | 68 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine)); |
69 rect.Set(0, 0, sz.x, sz.y); | 69 rect.Set(0, 0, sz.x, sz.y); |
70 } | 70 } |
71 rect.Inflate(kCaptionMargin, kCaptionMargin); | 71 rect.Inflate(kCaptionMargin, kCaptionMargin); |
72 | 72 |
73 IFWL_CheckBoxDP* pData = | 73 IFWL_CheckBox::DataProvider* pData = |
74 static_cast<IFWL_CheckBoxDP*>(m_pProperties->m_pDataProvider); | 74 static_cast<IFWL_CheckBox::DataProvider*>(m_pProperties->m_pDataProvider); |
75 FX_FLOAT fCheckBox = pData->GetBoxSize(this); | 75 FX_FLOAT fCheckBox = pData->GetBoxSize(this); |
76 rect.width += fCheckBox; | 76 rect.width += fCheckBox; |
77 rect.height = std::max(rect.height, fCheckBox); | 77 rect.height = std::max(rect.height, fCheckBox); |
78 IFWL_Widget::GetWidgetRect(rect, true); | 78 IFWL_Widget::GetWidgetRect(rect, true); |
79 } | 79 } |
80 | 80 |
81 void IFWL_CheckBox::Update() { | 81 void IFWL_CheckBox::Update() { |
82 if (IsLocked()) | 82 if (IsLocked()) |
83 return; | 83 return; |
84 if (!m_pProperties->m_pThemeProvider) | 84 if (!m_pProperties->m_pThemeProvider) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 m_pProperties->m_rtWidget.height = | 165 m_pProperties->m_rtWidget.height = |
166 FXSYS_round(m_pProperties->m_rtWidget.height); | 166 FXSYS_round(m_pProperties->m_rtWidget.height); |
167 GetClientRect(m_rtClient); | 167 GetClientRect(m_rtClient); |
168 | 168 |
169 if (!m_pProperties->m_pDataProvider) | 169 if (!m_pProperties->m_pDataProvider) |
170 return; | 170 return; |
171 | 171 |
172 FX_FLOAT fBoxTop = m_rtClient.top; | 172 FX_FLOAT fBoxTop = m_rtClient.top; |
173 FX_FLOAT fClientBottom = m_rtClient.bottom(); | 173 FX_FLOAT fClientBottom = m_rtClient.bottom(); |
174 | 174 |
175 IFWL_CheckBoxDP* pData = | 175 IFWL_CheckBox::DataProvider* pData = |
176 static_cast<IFWL_CheckBoxDP*>(m_pProperties->m_pDataProvider); | 176 static_cast<IFWL_CheckBox::DataProvider*>(m_pProperties->m_pDataProvider); |
177 FX_FLOAT fCheckBox = pData->GetBoxSize(this); | 177 FX_FLOAT fCheckBox = pData->GetBoxSize(this); |
178 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) { | 178 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) { |
179 case FWL_STYLEEXT_CKB_Top: | 179 case FWL_STYLEEXT_CKB_Top: |
180 break; | 180 break; |
181 case FWL_STYLEEXT_CKB_Bottom: { | 181 case FWL_STYLEEXT_CKB_Bottom: { |
182 fBoxTop = fClientBottom - fCheckBox; | 182 fBoxTop = fClientBottom - fCheckBox; |
183 break; | 183 break; |
184 } | 184 } |
185 case FWL_STYLEEXT_CKB_VCenter: | 185 case FWL_STYLEEXT_CKB_VCenter: |
186 default: { | 186 default: { |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 void IFWL_CheckBox::OnKeyDown(CFWL_MsgKey* pMsg) { | 502 void IFWL_CheckBox::OnKeyDown(CFWL_MsgKey* pMsg) { |
503 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { | 503 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { |
504 DispatchKeyEvent(pMsg); | 504 DispatchKeyEvent(pMsg); |
505 return; | 505 return; |
506 } | 506 } |
507 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || | 507 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || |
508 pMsg->m_dwKeyCode == FWL_VKEY_Space) { | 508 pMsg->m_dwKeyCode == FWL_VKEY_Space) { |
509 NextStates(); | 509 NextStates(); |
510 } | 510 } |
511 } | 511 } |
OLD | NEW |