| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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_comboedit.h" | 7 #include "xfa/fwl/core/ifwl_comboedit.h" |
| 8 | 8 |
| 9 #include "xfa/fde/cfde_txtedtengine.h" | 9 #include "xfa/fde/cfde_txtedtengine.h" |
| 10 #include "xfa/fwl/core/ifwl_combobox.h" | 10 #include "xfa/fwl/core/ifwl_combobox.h" |
| 11 | 11 |
| 12 IFWL_ComboEdit::IFWL_ComboEdit(const IFWL_App* app, | 12 IFWL_ComboEdit::IFWL_ComboEdit(const IFWL_App* app, |
| 13 const CFWL_WidgetImpProperties& properties, | 13 const CFWL_WidgetImpProperties& properties, |
| 14 IFWL_Widget* pOuter) | 14 IFWL_Widget* pOuter) |
| 15 : IFWL_Edit(app, properties, pOuter) { | 15 : IFWL_Edit(app, properties, pOuter) { |
| 16 m_pOuter = static_cast<IFWL_ComboBox*>(pOuter); | 16 m_pOuter = static_cast<IFWL_ComboBox*>(pOuter); |
| 17 } | 17 } |
| 18 | 18 |
| 19 void IFWL_ComboEdit::ClearSelected() { | 19 void IFWL_ComboEdit::ClearSelected() { |
| 20 ClearSelections(); | 20 ClearSelections(); |
| 21 Repaint(&m_rtClient); | 21 Repaint(&m_rtClient); |
| 22 } | 22 } |
| 23 | 23 |
| 24 void IFWL_ComboEdit::SetSelected() { | 24 void IFWL_ComboEdit::SetSelected() { |
| 25 FlagFocus(TRUE); | 25 FlagFocus(true); |
| 26 EndCaret(); | 26 EndCaret(); |
| 27 AddSelRange(0); | 27 AddSelRange(0); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void IFWL_ComboEdit::EndCaret() { | 30 void IFWL_ComboEdit::EndCaret() { |
| 31 m_pEdtEngine->MoveCaretPos(MC_End); | 31 m_pEdtEngine->MoveCaretPos(MC_End); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void IFWL_ComboEdit::FlagFocus(FX_BOOL bSet) { | 34 void IFWL_ComboEdit::FlagFocus(bool bSet) { |
| 35 if (bSet) { | 35 if (bSet) { |
| 36 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; | 36 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; |
| 37 } else { | 37 } else { |
| 38 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; | 38 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; |
| 39 ShowCaret(FALSE); | 39 ShowCaret(false); |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 void IFWL_ComboEdit::SetComboBoxFocus(FX_BOOL bSet) { | 43 void IFWL_ComboEdit::SetComboBoxFocus(bool bSet) { |
| 44 m_pOuter->SetFocus(bSet); | 44 m_pOuter->SetFocus(bSet); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void IFWL_ComboEdit::OnProcessMessage(CFWL_Message* pMessage) { | 47 void IFWL_ComboEdit::OnProcessMessage(CFWL_Message* pMessage) { |
| 48 if (!pMessage) | 48 if (!pMessage) |
| 49 return; | 49 return; |
| 50 | 50 |
| 51 FX_BOOL backDefault = TRUE; | 51 bool backDefault = true; |
| 52 switch (pMessage->GetClassID()) { | 52 switch (pMessage->GetClassID()) { |
| 53 case CFWL_MessageType::SetFocus: { | 53 case CFWL_MessageType::SetFocus: { |
| 54 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; | 54 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; |
| 55 backDefault = FALSE; | 55 backDefault = false; |
| 56 break; | 56 break; |
| 57 } | 57 } |
| 58 case CFWL_MessageType::KillFocus: { | 58 case CFWL_MessageType::KillFocus: { |
| 59 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; | 59 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; |
| 60 backDefault = FALSE; | 60 backDefault = false; |
| 61 break; | 61 break; |
| 62 } | 62 } |
| 63 case CFWL_MessageType::Mouse: { | 63 case CFWL_MessageType::Mouse: { |
| 64 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 64 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
| 65 if ((pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonDown) && | 65 if ((pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonDown) && |
| 66 ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)) { | 66 ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)) { |
| 67 SetSelected(); | 67 SetSelected(); |
| 68 SetComboBoxFocus(TRUE); | 68 SetComboBoxFocus(true); |
| 69 } | 69 } |
| 70 break; | 70 break; |
| 71 } | 71 } |
| 72 default: | 72 default: |
| 73 break; | 73 break; |
| 74 } | 74 } |
| 75 if (backDefault) | 75 if (backDefault) |
| 76 IFWL_Edit::OnProcessMessage(pMessage); | 76 IFWL_Edit::OnProcessMessage(pMessage); |
| 77 } | 77 } |
| OLD | NEW |