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

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

Issue 2560873005: Cleanup CFWL_Widget code to return CFX_RectFs where appropriate (Closed)
Patch Set: Review feedback 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
« no previous file with comments | « xfa/fwl/cfwl_caret.cpp ('k') | xfa/fwl/cfwl_combobox.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/cfwl_checkbox.h" 7 #include "xfa/fwl/cfwl_checkbox.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 case 1: 113 case 1:
114 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; 114 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked;
115 break; 115 break;
116 case 2: 116 case 2:
117 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) 117 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State)
118 m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral; 118 m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral;
119 break; 119 break;
120 default: 120 default:
121 break; 121 break;
122 } 122 }
123 Repaint(&m_rtClient); 123 RepaintRect(m_rtClient);
124 } 124 }
125 125
126 void CFWL_CheckBox::Layout() { 126 void CFWL_CheckBox::Layout() {
127 m_pProperties->m_rtWidget.width = 127 m_pProperties->m_rtWidget.width =
128 FXSYS_round(m_pProperties->m_rtWidget.width); 128 FXSYS_round(m_pProperties->m_rtWidget.width);
129 m_pProperties->m_rtWidget.height = 129 m_pProperties->m_rtWidget.height =
130 FXSYS_round(m_pProperties->m_rtWidget.height); 130 FXSYS_round(m_pProperties->m_rtWidget.height);
131 GetClientRect(m_rtClient); 131 m_rtClient = GetClientRect();
132 132
133 FX_FLOAT fBoxTop = m_rtClient.top; 133 FX_FLOAT fBoxTop = m_rtClient.top;
134 FX_FLOAT fClientBottom = m_rtClient.bottom(); 134 FX_FLOAT fClientBottom = m_rtClient.bottom();
135 135
136 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) { 136 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) {
137 case FWL_STYLEEXT_CKB_Top: 137 case FWL_STYLEEXT_CKB_Top:
138 break; 138 break;
139 case FWL_STYLEEXT_CKB_Bottom: { 139 case FWL_STYLEEXT_CKB_Bottom: {
140 fBoxTop = fClientBottom - m_fBoxHeight; 140 fBoxTop = fClientBottom - m_fBoxHeight;
141 break; 141 break;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 pWidgetMgr->GetSameGroupRadioButton(this, radioarr); 280 pWidgetMgr->GetSameGroupRadioButton(this, radioarr);
281 CFWL_CheckBox* pCheckBox = nullptr; 281 CFWL_CheckBox* pCheckBox = nullptr;
282 int32_t iCount = radioarr.GetSize(); 282 int32_t iCount = radioarr.GetSize();
283 for (int32_t i = 0; i < iCount; i++) { 283 for (int32_t i = 0; i < iCount; i++) {
284 pCheckBox = static_cast<CFWL_CheckBox*>(radioarr[i]); 284 pCheckBox = static_cast<CFWL_CheckBox*>(radioarr[i]);
285 if (pCheckBox != this && 285 if (pCheckBox != this &&
286 pCheckBox->GetStates() & FWL_STATE_CKB_Checked) { 286 pCheckBox->GetStates() & FWL_STATE_CKB_Checked) {
287 pCheckBox->SetCheckState(0); 287 pCheckBox->SetCheckState(0);
288 CFX_RectF rt = pCheckBox->GetWidgetRect(); 288 CFX_RectF rt = pCheckBox->GetWidgetRect();
289 rt.left = rt.top = 0; 289 rt.left = rt.top = 0;
290 m_pWidgetMgr->RepaintWidget(pCheckBox, &rt); 290 m_pWidgetMgr->RepaintWidget(pCheckBox, rt);
291 break; 291 break;
292 } 292 }
293 } 293 }
294 } 294 }
295 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; 295 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked;
296 } 296 }
297 } else { 297 } else {
298 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == 298 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
299 FWL_STATE_CKB_Neutral) { 299 FWL_STATE_CKB_Neutral) {
300 m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask; 300 m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask;
301 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) 301 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State)
302 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; 302 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked;
303 } else if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == 303 } else if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
304 FWL_STATE_CKB_Checked) { 304 FWL_STATE_CKB_Checked) {
305 m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask; 305 m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask;
306 } else { 306 } else {
307 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) 307 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State)
308 m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral; 308 m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral;
309 else 309 else
310 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; 310 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked;
311 } 311 }
312 } 312 }
313 313
314 Repaint(&m_rtClient); 314 RepaintRect(m_rtClient);
315 if (dwFirststate == m_pProperties->m_dwStates) 315 if (dwFirststate == m_pProperties->m_dwStates)
316 return; 316 return;
317 317
318 CFWL_Event wmCheckBoxState(CFWL_Event::Type::CheckStateChanged, this); 318 CFWL_Event wmCheckBoxState(CFWL_Event::Type::CheckStateChanged, this);
319 DispatchEvent(&wmCheckBoxState); 319 DispatchEvent(&wmCheckBoxState);
320 } 320 }
321 321
322 void CFWL_CheckBox::OnProcessMessage(CFWL_Message* pMessage) { 322 void CFWL_CheckBox::OnProcessMessage(CFWL_Message* pMessage) {
323 if (!pMessage) 323 if (!pMessage)
324 return; 324 return;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 const CFX_Matrix* pMatrix) { 367 const CFX_Matrix* pMatrix) {
368 DrawWidget(pGraphics, pMatrix); 368 DrawWidget(pGraphics, pMatrix);
369 } 369 }
370 370
371 void CFWL_CheckBox::OnFocusChanged(bool bSet) { 371 void CFWL_CheckBox::OnFocusChanged(bool bSet) {
372 if (bSet) 372 if (bSet)
373 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; 373 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
374 else 374 else
375 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; 375 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
376 376
377 Repaint(&m_rtClient); 377 RepaintRect(m_rtClient);
378 } 378 }
379 379
380 void CFWL_CheckBox::OnLButtonDown() { 380 void CFWL_CheckBox::OnLButtonDown() {
381 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) 381 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
382 return; 382 return;
383 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) 383 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
384 SetFocus(true); 384 SetFocus(true);
385 385
386 m_bBtnDown = true; 386 m_bBtnDown = true;
387 m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered; 387 m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered;
388 m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed; 388 m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed;
389 Repaint(&m_rtClient); 389 RepaintRect(m_rtClient);
390 } 390 }
391 391
392 void CFWL_CheckBox::OnLButtonUp(CFWL_MessageMouse* pMsg) { 392 void CFWL_CheckBox::OnLButtonUp(CFWL_MessageMouse* pMsg) {
393 if (!m_bBtnDown) 393 if (!m_bBtnDown)
394 return; 394 return;
395 395
396 m_bBtnDown = false; 396 m_bBtnDown = false;
397 if (!m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) 397 if (!m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy))
398 return; 398 return;
399 399
(...skipping 29 matching lines...) Expand all
429 } 429 }
430 } else { 430 } else {
431 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { 431 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
432 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) == 0) { 432 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) == 0) {
433 bRepaint = true; 433 bRepaint = true;
434 m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered; 434 m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
435 } 435 }
436 } 436 }
437 } 437 }
438 if (bRepaint) 438 if (bRepaint)
439 Repaint(&m_rtBox); 439 RepaintRect(m_rtBox);
440 } 440 }
441 441
442 void CFWL_CheckBox::OnMouseLeave() { 442 void CFWL_CheckBox::OnMouseLeave() {
443 if (m_bBtnDown) 443 if (m_bBtnDown)
444 m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered; 444 m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
445 else 445 else
446 m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered; 446 m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered;
447 447
448 Repaint(&m_rtBox); 448 RepaintRect(m_rtBox);
449 } 449 }
450 450
451 void CFWL_CheckBox::OnKeyDown(CFWL_MessageKey* pMsg) { 451 void CFWL_CheckBox::OnKeyDown(CFWL_MessageKey* pMsg) {
452 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) 452 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab)
453 return; 453 return;
454 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || 454 if (pMsg->m_dwKeyCode == FWL_VKEY_Return ||
455 pMsg->m_dwKeyCode == FWL_VKEY_Space) { 455 pMsg->m_dwKeyCode == FWL_VKEY_Space) {
456 NextStates(); 456 NextStates();
457 } 457 }
458 } 458 }
OLDNEW
« no previous file with comments | « xfa/fwl/cfwl_caret.cpp ('k') | xfa/fwl/cfwl_combobox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698