• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #include "xfa/fwl/cfwl_comboedit.h"
8 
9 #include "xfa/fde/cfde_texteditengine.h"
10 #include "xfa/fwl/cfwl_combobox.h"
11 #include "xfa/fwl/cfwl_messagemouse.h"
12 
13 namespace pdfium {
14 
CFWL_ComboEdit(CFWL_App * app,const Properties & properties,CFWL_Widget * pOuter)15 CFWL_ComboEdit::CFWL_ComboEdit(CFWL_App* app,
16                                const Properties& properties,
17                                CFWL_Widget* pOuter)
18     : CFWL_Edit(app, properties, pOuter) {}
19 
20 CFWL_ComboEdit::~CFWL_ComboEdit() = default;
21 
ClearSelected()22 void CFWL_ComboEdit::ClearSelected() {
23   ClearSelection();
24   RepaintRect(GetRTClient());
25 }
26 
SetSelected()27 void CFWL_ComboEdit::SetSelected() {
28   m_Properties.m_dwStates |= FWL_STATE_WGT_Focused;
29   SelectAll();
30 }
31 
OnProcessMessage(CFWL_Message * pMessage)32 void CFWL_ComboEdit::OnProcessMessage(CFWL_Message* pMessage) {
33   bool backDefault = true;
34   switch (pMessage->GetType()) {
35     case CFWL_Message::Type::kSetFocus: {
36       m_Properties.m_dwStates |= FWL_STATE_WGT_Focused;
37       backDefault = false;
38       break;
39     }
40     case CFWL_Message::Type::kKillFocus: {
41       m_Properties.m_dwStates &= ~FWL_STATE_WGT_Focused;
42       backDefault = false;
43       break;
44     }
45     case CFWL_Message::Type::kMouse: {
46       CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage);
47       if ((pMsg->m_dwCmd == CFWL_MessageMouse::MouseCommand::kLeftButtonDown) &&
48           ((m_Properties.m_dwStates & FWL_STATE_WGT_Focused) == 0)) {
49         SetSelected();
50       }
51       break;
52     }
53     default:
54       break;
55   }
56   if (backDefault)
57     CFWL_Edit::OnProcessMessage(pMessage);
58 }
59 
60 }  // namespace pdfium
61