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> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "third_party/base/ptr_util.h" | 13 #include "third_party/base/ptr_util.h" |
14 #include "xfa/fde/tto/fde_textout.h" | 14 #include "xfa/fde/tto/fde_textout.h" |
15 #include "xfa/fwl/core/cfwl_app.h" | 15 #include "xfa/fwl/core/cfwl_app.h" |
16 #include "xfa/fwl/core/cfwl_evtcheckstatechanged.h" | 16 #include "xfa/fwl/core/cfwl_event.h" |
17 #include "xfa/fwl/core/cfwl_msgkey.h" | 17 #include "xfa/fwl/core/cfwl_msgkey.h" |
18 #include "xfa/fwl/core/cfwl_msgmouse.h" | 18 #include "xfa/fwl/core/cfwl_msgmouse.h" |
19 #include "xfa/fwl/core/cfwl_notedriver.h" | 19 #include "xfa/fwl/core/cfwl_notedriver.h" |
20 #include "xfa/fwl/core/cfwl_themebackground.h" | 20 #include "xfa/fwl/core/cfwl_themebackground.h" |
21 #include "xfa/fwl/core/cfwl_themetext.h" | 21 #include "xfa/fwl/core/cfwl_themetext.h" |
22 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 22 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
23 #include "xfa/fwl/core/ifwl_themeprovider.h" | 23 #include "xfa/fwl/core/ifwl_themeprovider.h" |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral; | 332 m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral; |
333 else | 333 else |
334 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; | 334 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; |
335 } | 335 } |
336 } | 336 } |
337 | 337 |
338 Repaint(&m_rtClient); | 338 Repaint(&m_rtClient); |
339 if (dwFirststate == m_pProperties->m_dwStates) | 339 if (dwFirststate == m_pProperties->m_dwStates) |
340 return; | 340 return; |
341 | 341 |
342 CFWL_EvtCheckStateChanged wmCheckBoxState; | 342 CFWL_Event wmCheckBoxState(CFWL_Event::Type::CheckStateChanged, this); |
343 wmCheckBoxState.m_pSrcTarget = this; | |
344 DispatchEvent(&wmCheckBoxState); | 343 DispatchEvent(&wmCheckBoxState); |
345 } | 344 } |
346 | 345 |
347 void CFWL_CheckBox::OnProcessMessage(CFWL_Message* pMessage) { | 346 void CFWL_CheckBox::OnProcessMessage(CFWL_Message* pMessage) { |
348 if (!pMessage) | 347 if (!pMessage) |
349 return; | 348 return; |
350 | 349 |
351 switch (pMessage->GetClassID()) { | 350 switch (pMessage->GetType()) { |
352 case CFWL_MessageType::SetFocus: | 351 case CFWL_Message::Type::SetFocus: |
353 OnFocusChanged(true); | 352 OnFocusChanged(true); |
354 break; | 353 break; |
355 case CFWL_MessageType::KillFocus: | 354 case CFWL_Message::Type::KillFocus: |
356 OnFocusChanged(false); | 355 OnFocusChanged(false); |
357 break; | 356 break; |
358 case CFWL_MessageType::Mouse: { | 357 case CFWL_Message::Type::Mouse: { |
359 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 358 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
360 switch (pMsg->m_dwCmd) { | 359 switch (pMsg->m_dwCmd) { |
361 case FWL_MouseCommand::LeftButtonDown: | 360 case FWL_MouseCommand::LeftButtonDown: |
362 OnLButtonDown(); | 361 OnLButtonDown(); |
363 break; | 362 break; |
364 case FWL_MouseCommand::LeftButtonUp: | 363 case FWL_MouseCommand::LeftButtonUp: |
365 OnLButtonUp(pMsg); | 364 OnLButtonUp(pMsg); |
366 break; | 365 break; |
367 case FWL_MouseCommand::Move: | 366 case FWL_MouseCommand::Move: |
368 OnMouseMove(pMsg); | 367 OnMouseMove(pMsg); |
369 break; | 368 break; |
370 case FWL_MouseCommand::Leave: | 369 case FWL_MouseCommand::Leave: |
371 OnMouseLeave(); | 370 OnMouseLeave(); |
372 break; | 371 break; |
373 default: | 372 default: |
374 break; | 373 break; |
375 } | 374 } |
376 break; | 375 break; |
377 } | 376 } |
378 case CFWL_MessageType::Key: { | 377 case CFWL_Message::Type::Key: { |
379 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); | 378 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); |
380 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) | 379 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) |
381 OnKeyDown(pKey); | 380 OnKeyDown(pKey); |
382 break; | 381 break; |
383 } | 382 } |
384 default: | 383 default: |
385 break; | 384 break; |
386 } | 385 } |
387 | 386 |
388 CFWL_Widget::OnProcessMessage(pMessage); | 387 CFWL_Widget::OnProcessMessage(pMessage); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 void CFWL_CheckBox::OnMouseLeave() { | 466 void CFWL_CheckBox::OnMouseLeave() { |
468 if (m_bBtnDown) | 467 if (m_bBtnDown) |
469 m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered; | 468 m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered; |
470 else | 469 else |
471 m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered; | 470 m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered; |
472 | 471 |
473 Repaint(&m_rtBox); | 472 Repaint(&m_rtBox); |
474 } | 473 } |
475 | 474 |
476 void CFWL_CheckBox::OnKeyDown(CFWL_MsgKey* pMsg) { | 475 void CFWL_CheckBox::OnKeyDown(CFWL_MsgKey* pMsg) { |
477 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { | 476 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) |
478 DispatchKeyEvent(pMsg); | |
479 return; | 477 return; |
480 } | |
481 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || | 478 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || |
482 pMsg->m_dwKeyCode == FWL_VKEY_Space) { | 479 pMsg->m_dwKeyCode == FWL_VKEY_Space) { |
483 NextStates(); | 480 NextStates(); |
484 } | 481 } |
485 } | 482 } |
OLD | NEW |