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_checkbox.h" | 7 #include "xfa/fwl/core/cfwl_checkbox.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 CFWL_CheckBox::~CFWL_CheckBox() {} | 43 CFWL_CheckBox::~CFWL_CheckBox() {} |
44 | 44 |
45 FWL_Type CFWL_CheckBox::GetClassID() const { | 45 FWL_Type CFWL_CheckBox::GetClassID() const { |
46 return FWL_Type::CheckBox; | 46 return FWL_Type::CheckBox; |
47 } | 47 } |
48 | 48 |
49 void CFWL_CheckBox::SetBoxSize(FX_FLOAT fHeight) { | 49 void CFWL_CheckBox::SetBoxSize(FX_FLOAT fHeight) { |
50 m_fBoxHeight = fHeight; | 50 m_fBoxHeight = fHeight; |
51 } | 51 } |
52 | 52 |
53 void CFWL_CheckBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { | |
54 if (!bAutoSize) { | |
55 rect = m_pProperties->m_rtWidget; | |
56 return; | |
57 } | |
58 | |
59 rect.Set(0, 0, 0, 0); | |
60 if (!m_pProperties->m_pThemeProvider) | |
61 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | |
62 if (!m_pProperties->m_pThemeProvider) | |
63 return; | |
64 | |
65 CFX_SizeF sz = CalcTextSize( | |
66 L"Check box", m_pProperties->m_pThemeProvider, | |
67 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine)); | |
68 rect.Set(0, 0, sz.x, sz.y); | |
69 rect.Inflate(kCaptionMargin, kCaptionMargin); | |
70 | |
71 rect.width += m_fBoxHeight; | |
72 rect.height = std::max(rect.height, m_fBoxHeight); | |
73 InflateWidgetRect(rect); | |
74 } | |
75 | |
76 void CFWL_CheckBox::Update() { | 53 void CFWL_CheckBox::Update() { |
77 if (IsLocked()) | 54 if (IsLocked()) |
78 return; | 55 return; |
79 if (!m_pProperties->m_pThemeProvider) | 56 if (!m_pProperties->m_pThemeProvider) |
80 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 57 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
81 | 58 |
82 UpdateTextOutStyles(); | 59 UpdateTextOutStyles(); |
83 Layout(); | 60 Layout(); |
84 } | 61 } |
85 | 62 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 if (!pWidgetMgr->IsFormDisabled()) { | 278 if (!pWidgetMgr->IsFormDisabled()) { |
302 CFX_ArrayTemplate<CFWL_Widget*> radioarr; | 279 CFX_ArrayTemplate<CFWL_Widget*> radioarr; |
303 pWidgetMgr->GetSameGroupRadioButton(this, radioarr); | 280 pWidgetMgr->GetSameGroupRadioButton(this, radioarr); |
304 CFWL_CheckBox* pCheckBox = nullptr; | 281 CFWL_CheckBox* pCheckBox = nullptr; |
305 int32_t iCount = radioarr.GetSize(); | 282 int32_t iCount = radioarr.GetSize(); |
306 for (int32_t i = 0; i < iCount; i++) { | 283 for (int32_t i = 0; i < iCount; i++) { |
307 pCheckBox = static_cast<CFWL_CheckBox*>(radioarr[i]); | 284 pCheckBox = static_cast<CFWL_CheckBox*>(radioarr[i]); |
308 if (pCheckBox != this && | 285 if (pCheckBox != this && |
309 pCheckBox->GetStates() & FWL_STATE_CKB_Checked) { | 286 pCheckBox->GetStates() & FWL_STATE_CKB_Checked) { |
310 pCheckBox->SetCheckState(0); | 287 pCheckBox->SetCheckState(0); |
311 CFX_RectF rt; | 288 CFX_RectF rt = pCheckBox->GetWidgetRect(); |
312 pCheckBox->GetWidgetRect(rt, false); | |
313 rt.left = rt.top = 0; | 289 rt.left = rt.top = 0; |
314 m_pWidgetMgr->RepaintWidget(pCheckBox, &rt); | 290 m_pWidgetMgr->RepaintWidget(pCheckBox, &rt); |
315 break; | 291 break; |
316 } | 292 } |
317 } | 293 } |
318 } | 294 } |
319 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; | 295 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; |
320 } | 296 } |
321 } else { | 297 } else { |
322 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == | 298 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 } | 449 } |
474 | 450 |
475 void CFWL_CheckBox::OnKeyDown(CFWL_MsgKey* pMsg) { | 451 void CFWL_CheckBox::OnKeyDown(CFWL_MsgKey* pMsg) { |
476 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) | 452 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) |
477 return; | 453 return; |
478 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || | 454 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || |
479 pMsg->m_dwKeyCode == FWL_VKEY_Space) { | 455 pMsg->m_dwKeyCode == FWL_VKEY_Space) { |
480 NextStates(); | 456 NextStates(); |
481 } | 457 } |
482 } | 458 } |
OLD | NEW |