From 447b1f3ffc7e0df233d15300bbf8a85ce2bc7278 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Thu, 8 Dec 2016 10:06:32 -0800 Subject: Move xfa/fwl/core to xfa/fwl. The core/ directory in FWL no-longer provides any context. This Cl moves all of the core/ files up to the fwl/ folder. As well, the CFWL_EvtFoo files are renamed CFWL_EventFoo and the CFWL_MsgFoo files are renamed CFWL_MessageFoo. The event and message preceed the type in order to keep the files sorted together and to make it clear that they're all related. Review-Url: https://codereview.chromium.org/2559173002 --- xfa/fwl/core/cfwl_combolist.cpp | 245 ---------------------------------------- 1 file changed, 245 deletions(-) delete mode 100644 xfa/fwl/core/cfwl_combolist.cpp (limited to 'xfa/fwl/core/cfwl_combolist.cpp') diff --git a/xfa/fwl/core/cfwl_combolist.cpp b/xfa/fwl/core/cfwl_combolist.cpp deleted file mode 100644 index ff7bd2722c..0000000000 --- a/xfa/fwl/core/cfwl_combolist.cpp +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright 2016 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fwl/core/cfwl_combolist.h" - -#include -#include - -#include "third_party/base/ptr_util.h" -#include "xfa/fwl/core/cfwl_combobox.h" -#include "xfa/fwl/core/cfwl_comboedit.h" -#include "xfa/fwl/core/cfwl_listbox.h" -#include "xfa/fwl/core/cfwl_msgkey.h" -#include "xfa/fwl/core/cfwl_msgkillfocus.h" -#include "xfa/fwl/core/cfwl_msgmouse.h" - -CFWL_ComboList::CFWL_ComboList( - const CFWL_App* app, - std::unique_ptr properties, - CFWL_Widget* pOuter) - : CFWL_ListBox(app, std::move(properties), pOuter), m_bNotifyOwner(true) { - ASSERT(pOuter); -} - -int32_t CFWL_ComboList::MatchItem(const CFX_WideString& wsMatch) { - if (wsMatch.IsEmpty()) - return -1; - - int32_t iCount = CountItems(this); - for (int32_t i = 0; i < iCount; i++) { - CFWL_ListItem* hItem = GetItem(this, i); - CFX_WideString wsText = GetItemText(this, hItem); - FX_STRSIZE pos = wsText.Find(wsMatch.c_str()); - if (!pos) - return i; - } - return -1; -} - -void CFWL_ComboList::ChangeSelected(int32_t iSel) { - CFWL_ListItem* hItem = GetItem(this, iSel); - CFX_RectF rtInvalidate; - rtInvalidate.Reset(); - CFWL_ListItem* hOld = GetSelItem(0); - int32_t iOld = GetItemIndex(this, hOld); - if (iOld == iSel) - return; - if (iOld > -1) { - CFWL_ListItem* hItem = GetItem(this, iOld); - GetItemRect(this, hItem, rtInvalidate); - SetSelItem(hOld, false); - } - if (hItem) { - CFX_RectF rect; - CFWL_ListItem* hItem = GetItem(this, iSel); - GetItemRect(this, hItem, rect); - rtInvalidate.Union(rect); - CFWL_ListItem* hSel = GetItem(this, iSel); - SetSelItem(hSel, true); - } - if (!rtInvalidate.IsEmpty()) - Repaint(&rtInvalidate); -} - -void CFWL_ComboList::ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy) { - fx += m_pProperties->m_rtWidget.left, fy += m_pProperties->m_rtWidget.top; - CFWL_Widget* pOwner = GetOwner(); - if (!pOwner) - return; - pOwner->TransformTo(m_pOuter, fx, fy); -} - -void CFWL_ComboList::OnProcessMessage(CFWL_Message* pMessage) { - if (!pMessage) - return; - - CFWL_Message::Type type = pMessage->GetType(); - bool backDefault = true; - if (type == CFWL_Message::Type::SetFocus || - type == CFWL_Message::Type::KillFocus) { - OnDropListFocusChanged(pMessage, type == CFWL_Message::Type::SetFocus); - } else if (type == CFWL_Message::Type::Mouse) { - CFWL_MsgMouse* pMsg = static_cast(pMessage); - CFWL_ScrollBar* vertSB = GetVertScrollBar(); - if (IsShowScrollBar(true) && vertSB) { - CFX_RectF rect = vertSB->GetWidgetRect(); - if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) { - pMsg->m_fx -= rect.left; - pMsg->m_fy -= rect.top; - vertSB->GetDelegate()->OnProcessMessage(pMsg); - return; - } - } - switch (pMsg->m_dwCmd) { - case FWL_MouseCommand::Move: { - backDefault = false; - OnDropListMouseMove(pMsg); - break; - } - case FWL_MouseCommand::LeftButtonDown: { - backDefault = false; - OnDropListLButtonDown(pMsg); - break; - } - case FWL_MouseCommand::LeftButtonUp: { - backDefault = false; - OnDropListLButtonUp(pMsg); - break; - } - default: - break; - } - } else if (type == CFWL_Message::Type::Key) { - backDefault = !OnDropListKey(static_cast(pMessage)); - } - if (backDefault) - CFWL_ListBox::OnProcessMessage(pMessage); -} - -void CFWL_ComboList::OnDropListFocusChanged(CFWL_Message* pMsg, bool bSet) { - if (bSet) - return; - - CFWL_MsgKillFocus* pKill = static_cast(pMsg); - CFWL_ComboBox* pOuter = static_cast(m_pOuter); - if (pKill->m_pSetFocus == m_pOuter || - pKill->m_pSetFocus == pOuter->GetComboEdit()) { - pOuter->ShowDropList(false); - } -} - -void CFWL_ComboList::OnDropListMouseMove(CFWL_MsgMouse* pMsg) { - if (GetRTClient().Contains(pMsg->m_fx, pMsg->m_fy)) { - if (m_bNotifyOwner) - m_bNotifyOwner = false; - - CFWL_ScrollBar* vertSB = GetVertScrollBar(); - if (IsShowScrollBar(true) && vertSB) { - CFX_RectF rect = vertSB->GetWidgetRect(); - if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) - return; - } - - CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); - if (!hItem) - return; - - ChangeSelected(GetItemIndex(this, hItem)); - } else if (m_bNotifyOwner) { - ClientToOuter(pMsg->m_fx, pMsg->m_fy); - CFWL_ComboBox* pOuter = static_cast(m_pOuter); - pOuter->GetDelegate()->OnProcessMessage(pMsg); - } -} - -void CFWL_ComboList::OnDropListLButtonDown(CFWL_MsgMouse* pMsg) { - if (GetRTClient().Contains(pMsg->m_fx, pMsg->m_fy)) - return; - - CFWL_ComboBox* pOuter = static_cast(m_pOuter); - pOuter->ShowDropList(false); -} - -void CFWL_ComboList::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) { - CFWL_ComboBox* pOuter = static_cast(m_pOuter); - if (m_bNotifyOwner) { - ClientToOuter(pMsg->m_fx, pMsg->m_fy); - pOuter->GetDelegate()->OnProcessMessage(pMsg); - return; - } - - CFWL_ScrollBar* vertSB = GetVertScrollBar(); - if (IsShowScrollBar(true) && vertSB) { - CFX_RectF rect = vertSB->GetWidgetRect(); - if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) - return; - } - pOuter->ShowDropList(false); - - CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); - if (hItem) - pOuter->ProcessSelChanged(true); -} - -bool CFWL_ComboList::OnDropListKey(CFWL_MsgKey* pKey) { - CFWL_ComboBox* pOuter = static_cast(m_pOuter); - bool bPropagate = false; - if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) { - uint32_t dwKeyCode = pKey->m_dwKeyCode; - switch (dwKeyCode) { - case FWL_VKEY_Return: - case FWL_VKEY_Escape: { - pOuter->ShowDropList(false); - return true; - } - case FWL_VKEY_Up: - case FWL_VKEY_Down: { - OnDropListKeyDown(pKey); - pOuter->ProcessSelChanged(false); - return true; - } - default: { - bPropagate = true; - break; - } - } - } else if (pKey->m_dwCmd == FWL_KeyCommand::Char) { - bPropagate = true; - } - if (bPropagate) { - pKey->m_pDstTarget = m_pOuter; - pOuter->GetDelegate()->OnProcessMessage(pKey); - return true; - } - return false; -} - -void CFWL_ComboList::OnDropListKeyDown(CFWL_MsgKey* pKey) { - uint32_t dwKeyCode = pKey->m_dwKeyCode; - switch (dwKeyCode) { - case FWL_VKEY_Up: - case FWL_VKEY_Down: - case FWL_VKEY_Home: - case FWL_VKEY_End: { - CFWL_ComboBox* pOuter = static_cast(m_pOuter); - CFWL_ListItem* hItem = GetItem(this, pOuter->GetCurrentSelection()); - hItem = GetListItem(hItem, dwKeyCode); - if (!hItem) - break; - - SetSelection(hItem, hItem, true); - ScrollToVisible(hItem); - CFX_RectF rtInvalidate; - rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, - m_pProperties->m_rtWidget.height); - Repaint(&rtInvalidate); - break; - } - default: - break; - } -} -- cgit v1.2.3