Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: xfa/fwl/core/cfwl_checkbox.cpp

Issue 2556873004: Convert GetWidgetRect to return rect. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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) { 53 CFX_RectF CFWL_CheckBox::GetWidgetRect(bool bAutoSize) {
54 if (!bAutoSize) { 54 if (!bAutoSize)
55 rect = m_pProperties->m_rtWidget; 55 return m_pProperties->m_rtWidget;
56 return;
57 }
58 56
59 rect.Set(0, 0, 0, 0); 57 CFX_RectF rect;
60 if (!m_pProperties->m_pThemeProvider) 58 if (!m_pProperties->m_pThemeProvider)
61 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 59 m_pProperties->m_pThemeProvider = GetAvailableTheme();
62 if (!m_pProperties->m_pThemeProvider) 60 if (!m_pProperties->m_pThemeProvider)
63 return; 61 return rect;
64 62
65 CFX_SizeF sz = CalcTextSize( 63 CFX_SizeF sz = CalcTextSize(
66 L"Check box", m_pProperties->m_pThemeProvider, 64 L"Check box", m_pProperties->m_pThemeProvider,
67 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine)); 65 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine));
68 rect.Set(0, 0, sz.x, sz.y); 66 rect.Set(0, 0, sz.x, sz.y);
69 rect.Inflate(kCaptionMargin, kCaptionMargin); 67 rect.Inflate(kCaptionMargin, kCaptionMargin);
70 68
71 rect.width += m_fBoxHeight; 69 rect.width += m_fBoxHeight;
72 rect.height = std::max(rect.height, m_fBoxHeight); 70 rect.height = std::max(rect.height, m_fBoxHeight);
73 InflateWidgetRect(rect); 71 InflateWidgetRect(rect);
72 return rect;
74 } 73 }
75 74
76 void CFWL_CheckBox::Update() { 75 void CFWL_CheckBox::Update() {
77 if (IsLocked()) 76 if (IsLocked())
78 return; 77 return;
79 if (!m_pProperties->m_pThemeProvider) 78 if (!m_pProperties->m_pThemeProvider)
80 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 79 m_pProperties->m_pThemeProvider = GetAvailableTheme();
81 80
82 UpdateTextOutStyles(); 81 UpdateTextOutStyles();
83 Layout(); 82 Layout();
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 if (!pWidgetMgr->IsFormDisabled()) { 300 if (!pWidgetMgr->IsFormDisabled()) {
302 CFX_ArrayTemplate<CFWL_Widget*> radioarr; 301 CFX_ArrayTemplate<CFWL_Widget*> radioarr;
303 pWidgetMgr->GetSameGroupRadioButton(this, radioarr); 302 pWidgetMgr->GetSameGroupRadioButton(this, radioarr);
304 CFWL_CheckBox* pCheckBox = nullptr; 303 CFWL_CheckBox* pCheckBox = nullptr;
305 int32_t iCount = radioarr.GetSize(); 304 int32_t iCount = radioarr.GetSize();
306 for (int32_t i = 0; i < iCount; i++) { 305 for (int32_t i = 0; i < iCount; i++) {
307 pCheckBox = static_cast<CFWL_CheckBox*>(radioarr[i]); 306 pCheckBox = static_cast<CFWL_CheckBox*>(radioarr[i]);
308 if (pCheckBox != this && 307 if (pCheckBox != this &&
309 pCheckBox->GetStates() & FWL_STATE_CKB_Checked) { 308 pCheckBox->GetStates() & FWL_STATE_CKB_Checked) {
310 pCheckBox->SetCheckState(0); 309 pCheckBox->SetCheckState(0);
311 CFX_RectF rt; 310 CFX_RectF rt = pCheckBox->GetWidgetRect(false);
312 pCheckBox->GetWidgetRect(rt, false);
313 rt.left = rt.top = 0; 311 rt.left = rt.top = 0;
314 m_pWidgetMgr->RepaintWidget(pCheckBox, &rt); 312 m_pWidgetMgr->RepaintWidget(pCheckBox, &rt);
315 break; 313 break;
316 } 314 }
317 } 315 }
318 } 316 }
319 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; 317 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked;
320 } 318 }
321 } else { 319 } else {
322 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == 320 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 471 }
474 472
475 void CFWL_CheckBox::OnKeyDown(CFWL_MsgKey* pMsg) { 473 void CFWL_CheckBox::OnKeyDown(CFWL_MsgKey* pMsg) {
476 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) 474 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab)
477 return; 475 return;
478 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || 476 if (pMsg->m_dwKeyCode == FWL_VKEY_Return ||
479 pMsg->m_dwKeyCode == FWL_VKEY_Space) { 477 pMsg->m_dwKeyCode == FWL_VKEY_Space) {
480 NextStates(); 478 NextStates();
481 } 479 }
482 } 480 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698