| 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_pushbutton.h" | 7 #include "xfa/fwl/core/cfwl_pushbutton.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "third_party/base/ptr_util.h" | 12 #include "third_party/base/ptr_util.h" |
| 13 #include "xfa/fde/tto/fde_textout.h" | 13 #include "xfa/fde/tto/fde_textout.h" |
| 14 #include "xfa/fwl/core/cfwl_evtclick.h" | 14 #include "xfa/fwl/core/cfwl_event.h" |
| 15 #include "xfa/fwl/core/cfwl_evtmouse.h" | 15 #include "xfa/fwl/core/cfwl_evtmouse.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_notedriver.h" |
| 19 #include "xfa/fwl/core/cfwl_themebackground.h" | 19 #include "xfa/fwl/core/cfwl_themebackground.h" |
| 20 #include "xfa/fwl/core/cfwl_themetext.h" | 20 #include "xfa/fwl/core/cfwl_themetext.h" |
| 21 #include "xfa/fwl/core/ifwl_themeprovider.h" | 21 #include "xfa/fwl/core/ifwl_themeprovider.h" |
| 22 | 22 |
| 23 CFWL_PushButton::CFWL_PushButton(const CFWL_App* app) | 23 CFWL_PushButton::CFWL_PushButton(const CFWL_App* app) |
| 24 : CFWL_Widget(app, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr), | 24 : CFWL_Widget(app, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr), |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 void CFWL_PushButton::OnLButtonUp(CFWL_MsgMouse* pMsg) { | 241 void CFWL_PushButton::OnLButtonUp(CFWL_MsgMouse* pMsg) { |
| 242 m_bBtnDown = false; | 242 m_bBtnDown = false; |
| 243 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { | 243 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| 244 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; | 244 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; |
| 245 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; | 245 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; |
| 246 } else { | 246 } else { |
| 247 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; | 247 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; |
| 248 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; | 248 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; |
| 249 } | 249 } |
| 250 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { | 250 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| 251 CFWL_EvtClick wmClick; | 251 CFWL_Event wmClick(CFWL_EventType::Click); |
| 252 wmClick.m_pSrcTarget = this; | 252 wmClick.m_pSrcTarget = this; |
| 253 DispatchEvent(&wmClick); | 253 DispatchEvent(&wmClick); |
| 254 } | 254 } |
| 255 Repaint(&m_rtClient); | 255 Repaint(&m_rtClient); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void CFWL_PushButton::OnMouseMove(CFWL_MsgMouse* pMsg) { | 258 void CFWL_PushButton::OnMouseMove(CFWL_MsgMouse* pMsg) { |
| 259 bool bRepaint = false; | 259 bool bRepaint = false; |
| 260 if (m_bBtnDown) { | 260 if (m_bBtnDown) { |
| 261 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { | 261 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 290 } | 290 } |
| 291 | 291 |
| 292 void CFWL_PushButton::OnMouseLeave(CFWL_MsgMouse* pMsg) { | 292 void CFWL_PushButton::OnMouseLeave(CFWL_MsgMouse* pMsg) { |
| 293 m_bBtnDown = false; | 293 m_bBtnDown = false; |
| 294 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; | 294 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; |
| 295 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; | 295 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; |
| 296 Repaint(&m_rtClient); | 296 Repaint(&m_rtClient); |
| 297 } | 297 } |
| 298 | 298 |
| 299 void CFWL_PushButton::OnKeyDown(CFWL_MsgKey* pMsg) { | 299 void CFWL_PushButton::OnKeyDown(CFWL_MsgKey* pMsg) { |
| 300 if (pMsg->m_dwKeyCode == FWL_VKEY_Return) { | 300 if (pMsg->m_dwKeyCode != FWL_VKEY_Return) |
| 301 CFWL_EvtMouse wmMouse; | |
| 302 wmMouse.m_pSrcTarget = this; | |
| 303 wmMouse.m_dwCmd = FWL_MouseCommand::LeftButtonUp; | |
| 304 DispatchEvent(&wmMouse); | |
| 305 CFWL_EvtClick wmClick; | |
| 306 wmClick.m_pSrcTarget = this; | |
| 307 DispatchEvent(&wmClick); | |
| 308 return; | |
| 309 } | |
| 310 if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) | |
| 311 return; | 301 return; |
| 312 | 302 |
| 313 DispatchKeyEvent(pMsg); | 303 CFWL_EvtMouse wmMouse; |
| 304 wmMouse.m_pSrcTarget = this; |
| 305 wmMouse.m_dwCmd = FWL_MouseCommand::LeftButtonUp; |
| 306 DispatchEvent(&wmMouse); |
| 307 CFWL_Event wmClick(CFWL_EventType::Click); |
| 308 wmClick.m_pSrcTarget = this; |
| 309 DispatchEvent(&wmClick); |
| 314 } | 310 } |
| OLD | NEW |