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

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

Issue 2494743002: IFWL cleanup in the Combo classes (Closed)
Patch Set: Review feedback 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_comboedit.h ('k') | xfa/fwl/core/ifwl_combolist.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 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( 12 IFWL_ComboEdit::IFWL_ComboEdit(
13 const IFWL_App* app, 13 const IFWL_App* app,
14 std::unique_ptr<CFWL_WidgetProperties> properties, 14 std::unique_ptr<CFWL_WidgetProperties> properties,
15 IFWL_Widget* pOuter) 15 IFWL_Widget* pOuter)
16 : IFWL_Edit(app, std::move(properties), pOuter) { 16 : IFWL_Edit(app, std::move(properties), pOuter) {
17 m_pOuter = static_cast<IFWL_ComboBox*>(pOuter); 17 m_pOuter = static_cast<IFWL_ComboBox*>(pOuter);
18 } 18 }
19 19
20 void IFWL_ComboEdit::ClearSelected() { 20 void IFWL_ComboEdit::ClearSelected() {
21 ClearSelections(); 21 ClearSelections();
22 Repaint(&GetRTClient()); 22 Repaint(&GetRTClient());
23 } 23 }
24 24
25 void IFWL_ComboEdit::SetSelected() { 25 void IFWL_ComboEdit::SetSelected() {
26 FlagFocus(true); 26 FlagFocus(true);
27 EndCaret(); 27 GetTxtEdtEngine()->MoveCaretPos(MC_End);
28 AddSelRange(0); 28 AddSelRange(0);
29 } 29 }
30 30
31 void IFWL_ComboEdit::EndCaret() {
32 GetTxtEdtEngine()->MoveCaretPos(MC_End);
33 }
34
35 void IFWL_ComboEdit::FlagFocus(bool bSet) { 31 void IFWL_ComboEdit::FlagFocus(bool bSet) {
36 if (bSet) { 32 if (bSet) {
37 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; 33 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
38 } else { 34 } else {
39 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; 35 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
40 ShowCaret(false); 36 ShowCaret(false);
41 } 37 }
42 } 38 }
43 39
44 void IFWL_ComboEdit::SetComboBoxFocus(bool bSet) {
45 m_pOuter->SetFocus(bSet);
46 }
47
48 void IFWL_ComboEdit::OnProcessMessage(CFWL_Message* pMessage) { 40 void IFWL_ComboEdit::OnProcessMessage(CFWL_Message* pMessage) {
49 if (!pMessage) 41 if (!pMessage)
50 return; 42 return;
51 43
52 bool backDefault = true; 44 bool backDefault = true;
53 switch (pMessage->GetClassID()) { 45 switch (pMessage->GetClassID()) {
54 case CFWL_MessageType::SetFocus: { 46 case CFWL_MessageType::SetFocus: {
55 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; 47 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
56 backDefault = false; 48 backDefault = false;
57 break; 49 break;
58 } 50 }
59 case CFWL_MessageType::KillFocus: { 51 case CFWL_MessageType::KillFocus: {
60 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; 52 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
61 backDefault = false; 53 backDefault = false;
62 break; 54 break;
63 } 55 }
64 case CFWL_MessageType::Mouse: { 56 case CFWL_MessageType::Mouse: {
65 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); 57 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
66 if ((pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonDown) && 58 if ((pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonDown) &&
67 ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)) { 59 ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)) {
68 SetSelected(); 60 SetSelected();
69 SetComboBoxFocus(true); 61 m_pOuter->SetFocus(true);
70 } 62 }
71 break; 63 break;
72 } 64 }
73 default: 65 default:
74 break; 66 break;
75 } 67 }
76 if (backDefault) 68 if (backDefault)
77 IFWL_Edit::OnProcessMessage(pMessage); 69 IFWL_Edit::OnProcessMessage(pMessage);
78 } 70 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_comboedit.h ('k') | xfa/fwl/core/ifwl_combolist.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698