blob: 0be03d3a833dec61717de84ab010f7fce2696cf4 [file] [log] [blame]
kumarashishg826308d2023-06-23 13:21:22 +00001// Copyright 2016 The PDFium Authors
Philip P. Moltmann4d3acf42017-03-20 11:05:52 -07002// 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
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -07009#include "xfa/fde/cfde_texteditengine.h"
Philip P. Moltmann4d3acf42017-03-20 11:05:52 -070010#include "xfa/fwl/cfwl_combobox.h"
11#include "xfa/fwl/cfwl_messagemouse.h"
12
kumarashishg826308d2023-06-23 13:21:22 +000013CFWL_ComboEdit::CFWL_ComboEdit(CFWL_App* app,
14 const Properties& properties,
15 CFWL_Widget* pOuter)
16 : CFWL_Edit(app, properties, pOuter) {}
Philip P. Moltmann4d3acf42017-03-20 11:05:52 -070017
Haibo Huang49cc9302020-04-27 16:14:24 -070018CFWL_ComboEdit::~CFWL_ComboEdit() = default;
19
Philip P. Moltmann4d3acf42017-03-20 11:05:52 -070020void CFWL_ComboEdit::ClearSelected() {
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070021 ClearSelection();
Philip P. Moltmann4d3acf42017-03-20 11:05:52 -070022 RepaintRect(GetRTClient());
23}
24
25void CFWL_ComboEdit::SetSelected() {
kumarashishg826308d2023-06-23 13:21:22 +000026 m_Properties.m_dwStates |= FWL_STATE_WGT_Focused;
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070027 SelectAll();
Philip P. Moltmann4d3acf42017-03-20 11:05:52 -070028}
29
Philip P. Moltmann4d3acf42017-03-20 11:05:52 -070030void CFWL_ComboEdit::OnProcessMessage(CFWL_Message* pMessage) {
Philip P. Moltmann4d3acf42017-03-20 11:05:52 -070031 bool backDefault = true;
32 switch (pMessage->GetType()) {
kumarashishg826308d2023-06-23 13:21:22 +000033 case CFWL_Message::Type::kSetFocus: {
34 m_Properties.m_dwStates |= FWL_STATE_WGT_Focused;
Philip P. Moltmann4d3acf42017-03-20 11:05:52 -070035 backDefault = false;
36 break;
37 }
kumarashishg826308d2023-06-23 13:21:22 +000038 case CFWL_Message::Type::kKillFocus: {
39 m_Properties.m_dwStates &= ~FWL_STATE_WGT_Focused;
Philip P. Moltmann4d3acf42017-03-20 11:05:52 -070040 backDefault = false;
41 break;
42 }
kumarashishg826308d2023-06-23 13:21:22 +000043 case CFWL_Message::Type::kMouse: {
Philip P. Moltmann4d3acf42017-03-20 11:05:52 -070044 CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage);
kumarashishg826308d2023-06-23 13:21:22 +000045 if ((pMsg->m_dwCmd == CFWL_MessageMouse::MouseCommand::kLeftButtonDown) &&
46 ((m_Properties.m_dwStates & FWL_STATE_WGT_Focused) == 0)) {
Philip P. Moltmann4d3acf42017-03-20 11:05:52 -070047 SetSelected();
Philip P. Moltmann4d3acf42017-03-20 11:05:52 -070048 }
49 break;
50 }
51 default:
52 break;
53 }
54 if (backDefault)
55 CFWL_Edit::OnProcessMessage(pMessage);
56}