From ea7657c883f3bcf9136c00b46450ca4053bee766 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Thu, 15 Dec 2016 10:32:23 -0800 Subject: Remove unused sysbtn code This CL removes the unused FWL_WGTSTYLE_MinimizeBox, FWL_WGTSTYLE_MaximizeBox, and FWL_WGTSTYLE_CloseBox along with the supporting code. Review-Url: https://codereview.chromium.org/2578603002 --- BUILD.gn | 2 - xfa/fwl/cfwl_form.cpp | 299 +----------------------------------------------- xfa/fwl/cfwl_form.h | 21 ---- xfa/fwl/cfwl_sysbtn.cpp | 49 -------- xfa/fwl/cfwl_sysbtn.h | 33 ------ xfa/fwl/fwl_widgetdef.h | 5 +- 6 files changed, 4 insertions(+), 405 deletions(-) delete mode 100644 xfa/fwl/cfwl_sysbtn.cpp delete mode 100644 xfa/fwl/cfwl_sysbtn.h diff --git a/BUILD.gn b/BUILD.gn index 115fc8d0e4..b9f648fa95 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1268,8 +1268,6 @@ if (pdf_enable_xfa) { "xfa/fwl/cfwl_scrollbar.h", "xfa/fwl/cfwl_spinbutton.cpp", "xfa/fwl/cfwl_spinbutton.h", - "xfa/fwl/cfwl_sysbtn.cpp", - "xfa/fwl/cfwl_sysbtn.h", "xfa/fwl/cfwl_themebackground.h", "xfa/fwl/cfwl_themepart.cpp", "xfa/fwl/cfwl_themepart.h", diff --git a/xfa/fwl/cfwl_form.cpp b/xfa/fwl/cfwl_form.cpp index 78aba0c6db..75ddf43702 100644 --- a/xfa/fwl/cfwl_form.cpp +++ b/xfa/fwl/cfwl_form.cpp @@ -16,7 +16,6 @@ #include "xfa/fwl/cfwl_messagemouse.h" #include "xfa/fwl/cfwl_notedriver.h" #include "xfa/fwl/cfwl_noteloop.h" -#include "xfa/fwl/cfwl_sysbtn.h" #include "xfa/fwl/cfwl_themebackground.h" #include "xfa/fwl/cfwl_themepart.h" #include "xfa/fwl/cfwl_themetext.h" @@ -24,33 +23,13 @@ #include "xfa/fwl/ifwl_themeprovider.h" #include "xfa/fwl/theme/cfwl_widgettp.h" -namespace { - -const int kSystemButtonSize = 21; -const int kSystemButtonMargin = 5; -const int kSystemButtonSpan = 2; - -} // namespace - CFWL_Form::CFWL_Form(const CFWL_App* app, std::unique_ptr properties, CFWL_Widget* pOuter) : CFWL_Widget(app, std::move(properties), pOuter), -#if (_FX_OS_ == _FX_MACOSX_) - m_bMouseIn(false), -#endif - m_pCloseBox(nullptr), - m_pMinBox(nullptr), - m_pMaxBox(nullptr), m_pSubFocus(nullptr), m_fCXBorder(0), - m_fCYBorder(0), - m_iCaptureBtn(-1), - m_iSysBox(0), - m_bLButtonDown(false), - m_bMaximized(false), - m_bSetMaximize(false), - m_bDoModalFlag(false) { + m_fCYBorder(0) { m_rtRelative.Reset(); m_rtRestore.Reset(); @@ -61,7 +40,6 @@ CFWL_Form::CFWL_Form(const CFWL_App* app, CFWL_Form::~CFWL_Form() { UnregisterEventTarget(); UnRegisterForm(); - RemoveSysButtons(); } FWL_Type CFWL_Form::GetClassID() const { @@ -92,17 +70,8 @@ void CFWL_Form::Update() { FWL_WidgetHit CFWL_Form::HitTest(FX_FLOAT fx, FX_FLOAT fy) { GetAvailableTheme(); - if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) - return FWL_WidgetHit::CloseBox; - if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) - return FWL_WidgetHit::MaxBox; - if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) - return FWL_WidgetHit::MinBox; - CFX_RectF rtCap; - rtCap.Set(m_fCYBorder, m_fCXBorder, - 0 - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder, - 0 - m_fCXBorder); + rtCap.Set(m_fCYBorder, m_fCXBorder, -2 * m_fCYBorder, 0 - m_fCXBorder); return rtCap.Contains(fx, fy) ? FWL_WidgetHit::Titlebar : FWL_WidgetHit::Client; } @@ -139,65 +108,6 @@ void CFWL_Form::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { param.m_dwStates = iState; pTheme->DrawBackground(¶m); } - -#if (_FX_OS_ == _FX_MACOSX_) - { - if (m_pCloseBox) { - param.m_iPart = CFWL_Part::CloseBox; - param.m_dwStates = m_pCloseBox->GetPartState(); - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) - param.m_dwStates = CFWL_PartState_Disabled; - else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn) - param.m_dwStates = CFWL_PartState_Hovered; - param.m_rtPart = m_pCloseBox->m_rtBtn; - pTheme->DrawBackground(¶m); - } - if (m_pMaxBox) { - param.m_iPart = CFWL_Part::MaximizeBox; - param.m_dwStates = m_pMaxBox->GetPartState(); - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) - param.m_dwStates = CFWL_PartState_Disabled; - else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn) - param.m_dwStates = CFWL_PartState_Hovered; - param.m_rtPart = m_pMaxBox->m_rtBtn; - param.m_bMaximize = m_bMaximized; - pTheme->DrawBackground(¶m); - } - if (m_pMinBox) { - param.m_iPart = CFWL_Part::MinimizeBox; - param.m_dwStates = m_pMinBox->GetPartState(); - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) - param.m_dwStates = CFWL_PartState_Disabled; - else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn) - param.m_dwStates = CFWL_PartState_Hovered; - param.m_rtPart = m_pMinBox->m_rtBtn; - pTheme->DrawBackground(¶m); - } - m_bMouseIn = false; - } -#else - { - if (m_pCloseBox) { - param.m_iPart = CFWL_Part::CloseBox; - param.m_dwStates = m_pCloseBox->GetPartState(); - param.m_rtPart = m_pCloseBox->m_rtBtn; - pTheme->DrawBackground(¶m); - } - if (m_pMaxBox) { - param.m_iPart = CFWL_Part::MaximizeBox; - param.m_dwStates = m_pMaxBox->GetPartState(); - param.m_rtPart = m_pMaxBox->m_rtBtn; - param.m_bMaximize = m_bMaximized; - pTheme->DrawBackground(¶m); - } - if (m_pMinBox) { - param.m_iPart = CFWL_Part::MinimizeBox; - param.m_dwStates = m_pMinBox->GetPartState(); - param.m_rtPart = m_pMinBox->m_rtBtn; - pTheme->DrawBackground(¶m); - } - } -#endif } CFWL_Widget* CFWL_Form::DoModal() { @@ -213,7 +123,6 @@ CFWL_Widget* CFWL_Form::DoModal() { m_pNoteLoop->SetMainForm(this); pDriver->PushNoteLoop(m_pNoteLoop.get()); - m_bDoModalFlag = true; RemoveStates(FWL_WGTSTATE_Invisible); pDriver->Run(); @@ -229,8 +138,6 @@ void CFWL_Form::EndDoModal() { if (!m_pNoteLoop) return; - m_bDoModalFlag = false; - #if (_FX_OS_ == _FX_MACOSX_) m_pNoteLoop->EndModalLoop(); const CFWL_App* pApp = GetOwnerApp(); @@ -261,60 +168,6 @@ void CFWL_Form::DrawBackground(CFX_Graphics* pGraphics, pTheme->DrawBackground(¶m); } -void CFWL_Form::RemoveSysButtons() { - delete m_pCloseBox; - m_pCloseBox = nullptr; - delete m_pMinBox; - m_pMinBox = nullptr; - delete m_pMaxBox; - m_pMaxBox = nullptr; -} - -CFWL_SysBtn* CFWL_Form::GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy) { - if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) - return m_pCloseBox; - if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) - return m_pMaxBox; - if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) - return m_pMinBox; - return nullptr; -} - -CFWL_SysBtn* CFWL_Form::GetSysBtnByState(uint32_t dwState) { - if (m_pCloseBox && (m_pCloseBox->m_dwState & dwState)) - return m_pCloseBox; - if (m_pMaxBox && (m_pMaxBox->m_dwState & dwState)) - return m_pMaxBox; - if (m_pMinBox && (m_pMinBox->m_dwState & dwState)) - return m_pMinBox; - return nullptr; -} - -CFWL_SysBtn* CFWL_Form::GetSysBtnByIndex(int32_t nIndex) { - if (nIndex < 0) - return nullptr; - - CFX_ArrayTemplate arrBtn; - if (m_pMinBox) - arrBtn.Add(m_pMinBox); - if (m_pMaxBox) - arrBtn.Add(m_pMaxBox); - if (m_pCloseBox) - arrBtn.Add(m_pCloseBox); - return arrBtn[nIndex]; -} - -int32_t CFWL_Form::GetSysBtnIndex(CFWL_SysBtn* pBtn) { - CFX_ArrayTemplate arrBtn; - if (m_pMinBox) - arrBtn.Add(m_pMinBox); - if (m_pMaxBox) - arrBtn.Add(m_pMaxBox); - if (m_pCloseBox) - arrBtn.Add(m_pCloseBox); - return arrBtn.Find(pBtn); -} - CFX_RectF CFWL_Form::GetEdgeRect() { CFX_RectF rtEdge = m_rtRelative; if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) { @@ -330,8 +183,6 @@ void CFWL_Form::SetWorkAreaRect() { CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); if (!pWidgetMgr) return; - - m_bSetMaximize = true; RepaintRect(m_rtRelative); } @@ -339,55 +190,11 @@ void CFWL_Form::Layout() { m_rtRelative = GetRelativeRect(); #ifndef FWL_UseMacSystemBorder - ResetSysBtn(); -#endif -} - -void CFWL_Form::ResetSysBtn() { m_fCXBorder = *static_cast(GetThemeCapacity(CFWL_WidgetCapacity::CXBorder)); m_fCYBorder = *static_cast(GetThemeCapacity(CFWL_WidgetCapacity::CYBorder)); - RemoveSysButtons(); - - m_iSysBox = 0; - if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_CloseBox) { - m_pCloseBox = new CFWL_SysBtn; - m_pCloseBox->m_rtBtn.Set( - m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize, - kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize); - m_iSysBox++; - } - if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_MaximizeBox) { - m_pMaxBox = new CFWL_SysBtn; - if (m_pCloseBox) { - m_pMaxBox->m_rtBtn.Set( - m_pCloseBox->m_rtBtn.left - kSystemButtonSpan - kSystemButtonSize, - m_pCloseBox->m_rtBtn.top, kSystemButtonSize, kSystemButtonSize); - } else { - m_pMaxBox->m_rtBtn.Set( - m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize, - kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize); - } - m_iSysBox++; - } - if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_MinimizeBox) { - m_pMinBox = new CFWL_SysBtn; - if (m_pMaxBox) { - m_pMinBox->m_rtBtn.Set( - m_pMaxBox->m_rtBtn.left - kSystemButtonSpan - kSystemButtonSize, - m_pMaxBox->m_rtBtn.top, kSystemButtonSize, kSystemButtonSize); - } else if (m_pCloseBox) { - m_pMinBox->m_rtBtn.Set( - m_pCloseBox->m_rtBtn.left - kSystemButtonSpan - kSystemButtonSize, - m_pCloseBox->m_rtBtn.top, kSystemButtonSize, kSystemButtonSize); - } else { - m_pMinBox->m_rtBtn.Set( - m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize, - kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize); - } - m_iSysBox++; - } +#endif } void CFWL_Form::RegisterForm() { @@ -431,12 +238,6 @@ void CFWL_Form::OnProcessMessage(CFWL_Message* pMessage) { case FWL_MouseCommand::LeftButtonUp: OnLButtonUp(pMsg); break; - case FWL_MouseCommand::Move: - OnMouseMove(pMsg); - break; - case FWL_MouseCommand::Leave: - OnMouseLeave(pMsg); - break; default: break; } @@ -455,102 +256,8 @@ void CFWL_Form::OnDrawWidget(CFX_Graphics* pGraphics, void CFWL_Form::OnLButtonDown(CFWL_MessageMouse* pMsg) { SetGrab(true); - m_bLButtonDown = true; - - CFWL_SysBtn* pPressBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); - m_iCaptureBtn = GetSysBtnIndex(pPressBtn); - - if (!pPressBtn) - return; - - pPressBtn->SetPressed(); - RepaintRect(pPressBtn->m_rtBtn); } void CFWL_Form::OnLButtonUp(CFWL_MessageMouse* pMsg) { SetGrab(false); - m_bLButtonDown = false; - CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); - CFWL_SysBtn* pPressedBtn = GetSysBtnByIndex(m_iCaptureBtn); - if (!pPressedBtn || pPointBtn != pPressedBtn) - return; - if (pPressedBtn == GetSysBtnByState(FWL_SYSBUTTONSTATE_Pressed)) - pPressedBtn->SetNormal(); - if (pPressedBtn == m_pMaxBox) { - if (m_bMaximized) { - SetWidgetRect(m_rtRestore); - Update(); - Repaint(); - } else { - SetWorkAreaRect(); - Update(); - } - m_bMaximized = !m_bMaximized; - } else if (pPressedBtn != m_pMinBox) { - CFWL_Event eClose(CFWL_Event::Type::Close, this); - DispatchEvent(&eClose); - } -} - -void CFWL_Form::OnMouseMove(CFWL_MessageMouse* pMsg) { - if (m_bLButtonDown) - return; - - CFX_RectF rtInvalidate; - rtInvalidate.Reset(); - CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); - CFWL_SysBtn* pOldHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); - -#if _FX_OS_ == _FX_MACOSX_ - { - if (pOldHover && pPointBtn != pOldHover) - pOldHover->SetNormal(); - if (pPointBtn && pPointBtn != pOldHover) - pPointBtn->SetHover(); - if (m_pCloseBox) - rtInvalidate = m_pCloseBox->m_rtBtn; - if (m_pMaxBox) { - if (rtInvalidate.IsEmpty()) - rtInvalidate = m_pMaxBox->m_rtBtn; - else - rtInvalidate.Union(m_pMaxBox->m_rtBtn); - } - if (m_pMinBox) { - if (rtInvalidate.IsEmpty()) - rtInvalidate = m_pMinBox->m_rtBtn; - else - rtInvalidate.Union(m_pMinBox->m_rtBtn); - } - if (!rtInvalidate.IsEmpty() && - rtInvalidate.Contains(pMsg->m_fx, pMsg->m_fy)) { - m_bMouseIn = true; - } - } -#else - { - if (pOldHover && pPointBtn != pOldHover) { - pOldHover->SetNormal(); - rtInvalidate = pOldHover->m_rtBtn; - } - if (pPointBtn && pPointBtn != pOldHover) { - pPointBtn->SetHover(); - if (rtInvalidate.IsEmpty()) - rtInvalidate = pPointBtn->m_rtBtn; - else - rtInvalidate.Union(pPointBtn->m_rtBtn); - } - } -#endif - - if (!rtInvalidate.IsEmpty()) - RepaintRect(rtInvalidate); -} - -void CFWL_Form::OnMouseLeave(CFWL_MessageMouse* pMsg) { - CFWL_SysBtn* pHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); - if (!pHover) - return; - - pHover->SetNormal(); - RepaintRect(pHover->m_rtBtn); } diff --git a/xfa/fwl/cfwl_form.h b/xfa/fwl/cfwl_form.h index e89350ba3b..4297fde86e 100644 --- a/xfa/fwl/cfwl_form.h +++ b/xfa/fwl/cfwl_form.h @@ -24,7 +24,6 @@ class CFWL_MessageMouse; class CFWL_NoteLoop; class CFWL_Widget; class IFWL_ThemeProvider; -class CFWL_SysBtn; class CFWL_Form : public CFWL_Widget { public: @@ -52,40 +51,20 @@ class CFWL_Form : public CFWL_Widget { private: void DrawBackground(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme); - void RemoveSysButtons(); - CFWL_SysBtn* GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy); - CFWL_SysBtn* GetSysBtnByState(uint32_t dwState); - CFWL_SysBtn* GetSysBtnByIndex(int32_t nIndex); - int32_t GetSysBtnIndex(CFWL_SysBtn* pBtn); CFX_RectF GetEdgeRect(); void SetWorkAreaRect(); void Layout(); - void ResetSysBtn(); void RegisterForm(); void UnRegisterForm(); void OnLButtonDown(CFWL_MessageMouse* pMsg); void OnLButtonUp(CFWL_MessageMouse* pMsg); - void OnMouseMove(CFWL_MessageMouse* pMsg); - void OnMouseLeave(CFWL_MessageMouse* pMsg); -#if (_FX_OS_ == _FX_MACOSX_) - bool m_bMouseIn; -#endif CFX_RectF m_rtRestore; CFX_RectF m_rtRelative; - CFWL_SysBtn* m_pCloseBox; - CFWL_SysBtn* m_pMinBox; - CFWL_SysBtn* m_pMaxBox; std::unique_ptr m_pNoteLoop; CFWL_Widget* m_pSubFocus; FX_FLOAT m_fCXBorder; FX_FLOAT m_fCYBorder; - int32_t m_iCaptureBtn; - int32_t m_iSysBox; - bool m_bLButtonDown; - bool m_bMaximized; - bool m_bSetMaximize; - bool m_bDoModalFlag; }; #endif // XFA_FWL_CFWL_FORM_H_ diff --git a/xfa/fwl/cfwl_sysbtn.cpp b/xfa/fwl/cfwl_sysbtn.cpp deleted file mode 100644 index 6f78d0245d..0000000000 --- a/xfa/fwl/cfwl_sysbtn.cpp +++ /dev/null @@ -1,49 +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/cfwl_sysbtn.h" - -#include "xfa/fwl/cfwl_themepart.h" - -CFWL_SysBtn::CFWL_SysBtn() { - m_rtBtn.Set(0, 0, 0, 0); - m_dwState = 0; -} - -CFWL_SysBtn::~CFWL_SysBtn() {} - -bool CFWL_SysBtn::IsDisabled() const { - return !!(m_dwState & FWL_SYSBUTTONSTATE_Disabled); -} - -void CFWL_SysBtn::SetNormal() { - m_dwState &= 0xFFF0; -} - -void CFWL_SysBtn::SetPressed() { - SetNormal(); - m_dwState |= FWL_SYSBUTTONSTATE_Pressed; -} - -void CFWL_SysBtn::SetHover() { - SetNormal(); - m_dwState |= FWL_SYSBUTTONSTATE_Hover; -} - -void CFWL_SysBtn::SetDisabled(bool bDisabled) { - bDisabled ? m_dwState |= FWL_SYSBUTTONSTATE_Disabled - : m_dwState &= ~FWL_SYSBUTTONSTATE_Disabled; -} - -uint32_t CFWL_SysBtn::GetPartState() const { - if (IsDisabled()) - return CFWL_PartState_Disabled; - if (m_dwState & FWL_SYSBUTTONSTATE_Pressed) - return CFWL_PartState_Pressed; - if (m_dwState & FWL_SYSBUTTONSTATE_Hover) - return CFWL_PartState_Hovered; - return CFWL_PartState_Normal; -} diff --git a/xfa/fwl/cfwl_sysbtn.h b/xfa/fwl/cfwl_sysbtn.h deleted file mode 100644 index e79b438f6a..0000000000 --- a/xfa/fwl/cfwl_sysbtn.h +++ /dev/null @@ -1,33 +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 - -#ifndef XFA_FWL_CFWL_SYSBTN_H_ -#define XFA_FWL_CFWL_SYSBTN_H_ - -#include "core/fxcrt/fx_coordinates.h" - -#define FWL_SYSBUTTONSTATE_Hover 0x0001 -#define FWL_SYSBUTTONSTATE_Pressed 0x0002 -#define FWL_SYSBUTTONSTATE_Disabled 0x0010 - -class CFWL_SysBtn { - public: - CFWL_SysBtn(); - ~CFWL_SysBtn(); - - bool IsDisabled() const; - uint32_t GetPartState() const; - - void SetNormal(); - void SetPressed(); - void SetHover(); - void SetDisabled(bool bDisabled); - - CFX_RectF m_rtBtn; - uint32_t m_dwState; -}; - -#endif // XFA_FWL_CFWL_SYSBTN_H_ diff --git a/xfa/fwl/fwl_widgetdef.h b/xfa/fwl/fwl_widgetdef.h index a11c211abd..fd90fd3bab 100644 --- a/xfa/fwl/fwl_widgetdef.h +++ b/xfa/fwl/fwl_widgetdef.h @@ -7,13 +7,10 @@ #ifndef XFA_FWL_FWL_WIDGETDEF_H_ #define XFA_FWL_FWL_WIDGETDEF_H_ -#define FWL_WGTSTYLE_OverLapper (0L << 0) +#define FWL_WGTSTYLE_OverLapper 0 #define FWL_WGTSTYLE_Popup (1L << 0) #define FWL_WGTSTYLE_Child (2L << 0) #define FWL_WGTSTYLE_Border (1L << 2) -#define FWL_WGTSTYLE_MinimizeBox (1L << 6) -#define FWL_WGTSTYLE_MaximizeBox (1L << 7) -#define FWL_WGTSTYLE_CloseBox (1L << 8) #define FWL_WGTSTYLE_HScroll (1L << 9) #define FWL_WGTSTYLE_VScroll (1L << 11) #define FWL_WGTSTYLE_LeftScrollbar (1L << 12) -- cgit v1.2.3