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

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

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: Created 4 years, 1 month 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/core/ifwl_pushbutton.h ('k') | xfa/fwl/core/ifwl_scrollbar.h » ('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/core/ifwl_pushbutton.h" 7 #include "xfa/fwl/core/ifwl_pushbutton.h"
8 8
9 #include "third_party/base/ptr_util.h" 9 #include "third_party/base/ptr_util.h"
10 #include "xfa/fde/tto/fde_textout.h" 10 #include "xfa/fde/tto/fde_textout.h"
11 #include "xfa/fwl/core/cfwl_message.h" 11 #include "xfa/fwl/core/cfwl_message.h"
12 #include "xfa/fwl/core/cfwl_themebackground.h" 12 #include "xfa/fwl/core/cfwl_themebackground.h"
13 #include "xfa/fwl/core/cfwl_themetext.h" 13 #include "xfa/fwl/core/cfwl_themetext.h"
14 #include "xfa/fwl/core/fwl_noteimp.h" 14 #include "xfa/fwl/core/fwl_noteimp.h"
15 #include "xfa/fwl/core/ifwl_pushbutton.h" 15 #include "xfa/fwl/core/ifwl_pushbutton.h"
16 #include "xfa/fwl/core/ifwl_themeprovider.h" 16 #include "xfa/fwl/core/ifwl_themeprovider.h"
17 17
18 IFWL_PushButton::IFWL_PushButton(const IFWL_App* app, 18 IFWL_PushButton::IFWL_PushButton(const IFWL_App* app,
19 const CFWL_WidgetImpProperties& properties) 19 const CFWL_WidgetImpProperties& properties)
20 : IFWL_Widget(app, properties, nullptr), 20 : IFWL_Widget(app, properties, nullptr),
21 m_bBtnDown(FALSE), 21 m_bBtnDown(false),
22 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), 22 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
23 m_iTTOAlign(FDE_TTOALIGNMENT_Center) { 23 m_iTTOAlign(FDE_TTOALIGNMENT_Center) {
24 m_rtClient.Set(0, 0, 0, 0); 24 m_rtClient.Set(0, 0, 0, 0);
25 m_rtCaption.Set(0, 0, 0, 0); 25 m_rtCaption.Set(0, 0, 0, 0);
26 } 26 }
27 27
28 IFWL_PushButton::~IFWL_PushButton() {} 28 IFWL_PushButton::~IFWL_PushButton() {}
29 29
30 FWL_Type IFWL_PushButton::GetClassID() const { 30 FWL_Type IFWL_PushButton::GetClassID() const {
31 return FWL_Type::PushButton; 31 return FWL_Type::PushButton;
32 } 32 }
33 33
34 FWL_Error IFWL_PushButton::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { 34 FWL_Error IFWL_PushButton::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
35 if (bAutoSize) { 35 if (bAutoSize) {
36 rect.Set(0, 0, 0, 0); 36 rect.Set(0, 0, 0, 0);
37 if (!m_pProperties->m_pThemeProvider) { 37 if (!m_pProperties->m_pThemeProvider) {
38 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 38 m_pProperties->m_pThemeProvider = GetAvailableTheme();
39 } 39 }
40 CFX_WideString wsCaption; 40 CFX_WideString wsCaption;
41 IFWL_PushButtonDP* pData = 41 IFWL_PushButtonDP* pData =
42 static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider); 42 static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider);
43 if (pData) { 43 if (pData) {
44 pData->GetCaption(this, wsCaption); 44 pData->GetCaption(this, wsCaption);
45 } 45 }
46 int32_t iLen = wsCaption.GetLength(); 46 int32_t iLen = wsCaption.GetLength();
47 if (iLen > 0) { 47 if (iLen > 0) {
48 CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider); 48 CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider);
49 rect.Set(0, 0, sz.x, sz.y); 49 rect.Set(0, 0, sz.x, sz.y);
50 } 50 }
51 FX_FLOAT* fcaption = 51 FX_FLOAT* fcaption =
52 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin)); 52 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin));
53 rect.Inflate(*fcaption, *fcaption); 53 rect.Inflate(*fcaption, *fcaption);
54 IFWL_Widget::GetWidgetRect(rect, TRUE); 54 IFWL_Widget::GetWidgetRect(rect, true);
55 } else { 55 } else {
56 rect = m_pProperties->m_rtWidget; 56 rect = m_pProperties->m_rtWidget;
57 } 57 }
58 return FWL_Error::Succeeded; 58 return FWL_Error::Succeeded;
59 } 59 }
60 60
61 void IFWL_PushButton::SetStates(uint32_t dwStates, FX_BOOL bSet) { 61 void IFWL_PushButton::SetStates(uint32_t dwStates, bool bSet) {
62 if ((dwStates & FWL_WGTSTATE_Disabled) && bSet) { 62 if ((dwStates & FWL_WGTSTATE_Disabled) && bSet) {
63 m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled; 63 m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled;
64 return; 64 return;
65 } 65 }
66 IFWL_Widget::SetStates(dwStates, bSet); 66 IFWL_Widget::SetStates(dwStates, bSet);
67 } 67 }
68 68
69 FWL_Error IFWL_PushButton::Update() { 69 FWL_Error IFWL_PushButton::Update() {
70 if (IsLocked()) { 70 if (IsLocked()) {
71 return FWL_Error::Indefinite; 71 return FWL_Error::Indefinite;
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 381
382 void IFWL_PushButton::OnProcessMessage(CFWL_Message* pMessage) { 382 void IFWL_PushButton::OnProcessMessage(CFWL_Message* pMessage) {
383 if (!pMessage) 383 if (!pMessage)
384 return; 384 return;
385 if (!IsEnabled()) 385 if (!IsEnabled())
386 return; 386 return;
387 387
388 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); 388 CFWL_MessageType dwMsgCode = pMessage->GetClassID();
389 switch (dwMsgCode) { 389 switch (dwMsgCode) {
390 case CFWL_MessageType::SetFocus: 390 case CFWL_MessageType::SetFocus:
391 OnFocusChanged(pMessage, TRUE); 391 OnFocusChanged(pMessage, true);
392 break; 392 break;
393 case CFWL_MessageType::KillFocus: 393 case CFWL_MessageType::KillFocus:
394 OnFocusChanged(pMessage, FALSE); 394 OnFocusChanged(pMessage, false);
395 break; 395 break;
396 case CFWL_MessageType::Mouse: { 396 case CFWL_MessageType::Mouse: {
397 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); 397 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
398 switch (pMsg->m_dwCmd) { 398 switch (pMsg->m_dwCmd) {
399 case FWL_MouseCommand::LeftButtonDown: 399 case FWL_MouseCommand::LeftButtonDown:
400 OnLButtonDown(pMsg); 400 OnLButtonDown(pMsg);
401 break; 401 break;
402 case FWL_MouseCommand::LeftButtonUp: 402 case FWL_MouseCommand::LeftButtonUp:
403 OnLButtonUp(pMsg); 403 OnLButtonUp(pMsg);
404 break; 404 break;
(...skipping 18 matching lines...) Expand all
423 break; 423 break;
424 } 424 }
425 IFWL_Widget::OnProcessMessage(pMessage); 425 IFWL_Widget::OnProcessMessage(pMessage);
426 } 426 }
427 427
428 void IFWL_PushButton::OnDrawWidget(CFX_Graphics* pGraphics, 428 void IFWL_PushButton::OnDrawWidget(CFX_Graphics* pGraphics,
429 const CFX_Matrix* pMatrix) { 429 const CFX_Matrix* pMatrix) {
430 DrawWidget(pGraphics, pMatrix); 430 DrawWidget(pGraphics, pMatrix);
431 } 431 }
432 432
433 void IFWL_PushButton::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { 433 void IFWL_PushButton::OnFocusChanged(CFWL_Message* pMsg, bool bSet) {
434 if (bSet) 434 if (bSet)
435 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; 435 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
436 else 436 else
437 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; 437 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
438 438
439 Repaint(&m_rtClient); 439 Repaint(&m_rtClient);
440 } 440 }
441 441
442 void IFWL_PushButton::OnLButtonDown(CFWL_MsgMouse* pMsg) { 442 void IFWL_PushButton::OnLButtonDown(CFWL_MsgMouse* pMsg) {
443 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) 443 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
444 SetFocus(TRUE); 444 SetFocus(true);
445 445
446 m_bBtnDown = TRUE; 446 m_bBtnDown = true;
447 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; 447 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
448 m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed; 448 m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed;
449 Repaint(&m_rtClient); 449 Repaint(&m_rtClient);
450 } 450 }
451 451
452 void IFWL_PushButton::OnLButtonUp(CFWL_MsgMouse* pMsg) { 452 void IFWL_PushButton::OnLButtonUp(CFWL_MsgMouse* pMsg) {
453 m_bBtnDown = FALSE; 453 m_bBtnDown = false;
454 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { 454 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
455 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; 455 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
456 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; 456 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
457 } else { 457 } else {
458 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; 458 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
459 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; 459 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
460 } 460 }
461 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { 461 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
462 CFWL_EvtClick wmClick; 462 CFWL_EvtClick wmClick;
463 wmClick.m_pSrcTarget = this; 463 wmClick.m_pSrcTarget = this;
464 DispatchEvent(&wmClick); 464 DispatchEvent(&wmClick);
465 } 465 }
466 Repaint(&m_rtClient); 466 Repaint(&m_rtClient);
467 } 467 }
468 468
469 void IFWL_PushButton::OnMouseMove(CFWL_MsgMouse* pMsg) { 469 void IFWL_PushButton::OnMouseMove(CFWL_MsgMouse* pMsg) {
470 FX_BOOL bRepaint = FALSE; 470 bool bRepaint = false;
471 if (m_bBtnDown) { 471 if (m_bBtnDown) {
472 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { 472 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
473 if ((m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) == 0) { 473 if ((m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) == 0) {
474 m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed; 474 m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed;
475 bRepaint = TRUE; 475 bRepaint = true;
476 } 476 }
477 if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) { 477 if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) {
478 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; 478 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
479 bRepaint = TRUE; 479 bRepaint = true;
480 } 480 }
481 } else { 481 } else {
482 if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) { 482 if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) {
483 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; 483 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
484 bRepaint = TRUE; 484 bRepaint = true;
485 } 485 }
486 if ((m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) { 486 if ((m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) {
487 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; 487 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
488 bRepaint = TRUE; 488 bRepaint = true;
489 } 489 }
490 } 490 }
491 } else { 491 } else {
492 if (!m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) 492 if (!m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy))
493 return; 493 return;
494 if ((m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) { 494 if ((m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) {
495 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; 495 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
496 bRepaint = TRUE; 496 bRepaint = true;
497 } 497 }
498 } 498 }
499 if (bRepaint) 499 if (bRepaint)
500 Repaint(&m_rtClient); 500 Repaint(&m_rtClient);
501 } 501 }
502 502
503 void IFWL_PushButton::OnMouseLeave(CFWL_MsgMouse* pMsg) { 503 void IFWL_PushButton::OnMouseLeave(CFWL_MsgMouse* pMsg) {
504 m_bBtnDown = FALSE; 504 m_bBtnDown = false;
505 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; 505 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
506 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; 506 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
507 Repaint(&m_rtClient); 507 Repaint(&m_rtClient);
508 } 508 }
509 509
510 void IFWL_PushButton::OnKeyDown(CFWL_MsgKey* pMsg) { 510 void IFWL_PushButton::OnKeyDown(CFWL_MsgKey* pMsg) {
511 if (pMsg->m_dwKeyCode == FWL_VKEY_Return) { 511 if (pMsg->m_dwKeyCode == FWL_VKEY_Return) {
512 CFWL_EvtMouse wmMouse; 512 CFWL_EvtMouse wmMouse;
513 wmMouse.m_pSrcTarget = this; 513 wmMouse.m_pSrcTarget = this;
514 wmMouse.m_dwCmd = FWL_MouseCommand::LeftButtonUp; 514 wmMouse.m_dwCmd = FWL_MouseCommand::LeftButtonUp;
515 DispatchEvent(&wmMouse); 515 DispatchEvent(&wmMouse);
516 CFWL_EvtClick wmClick; 516 CFWL_EvtClick wmClick;
517 wmClick.m_pSrcTarget = this; 517 wmClick.m_pSrcTarget = this;
518 DispatchEvent(&wmClick); 518 DispatchEvent(&wmClick);
519 return; 519 return;
520 } 520 }
521 if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) 521 if (pMsg->m_dwKeyCode != FWL_VKEY_Tab)
522 return; 522 return;
523 523
524 DispatchKeyEvent(pMsg); 524 DispatchKeyEvent(pMsg);
525 } 525 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_pushbutton.h ('k') | xfa/fwl/core/ifwl_scrollbar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698