Index: xfa/fwl/core/ifwl_pushbutton.cpp |
diff --git a/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp b/xfa/fwl/core/ifwl_pushbutton.cpp |
similarity index 87% |
rename from xfa/fwl/basewidget/fwl_pushbuttonimp.cpp |
rename to xfa/fwl/core/ifwl_pushbutton.cpp |
index 834342ec93edaf1576c4bcbc832c52a433bd4d31..a3efb102960b4df1aa90d726d075a480bc8740af 100644 |
--- a/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp |
+++ b/xfa/fwl/core/ifwl_pushbutton.cpp |
@@ -4,34 +4,26 @@ |
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
-#include "xfa/fwl/basewidget/fwl_pushbuttonimp.h" |
+#include "xfa/fwl/core/ifwl_pushbutton.h" |
#include "xfa/fde/tto/fde_textout.h" |
-#include "xfa/fwl/basewidget/ifwl_pushbutton.h" |
#include "xfa/fwl/core/cfwl_message.h" |
#include "xfa/fwl/core/cfwl_themebackground.h" |
#include "xfa/fwl/core/cfwl_themetext.h" |
#include "xfa/fwl/core/fwl_noteimp.h" |
-#include "xfa/fwl/core/fwl_widgetimp.h" |
+#include "xfa/fwl/core/ifwl_pushbutton.h" |
#include "xfa/fwl/core/ifwl_themeprovider.h" |
// static |
IFWL_PushButton* IFWL_PushButton::Create( |
const CFWL_WidgetImpProperties& properties, |
IFWL_Widget* pOuter) { |
- IFWL_PushButton* pPushButton = new IFWL_PushButton; |
- CFWL_PushButtonImp* pPushButtonImpl = |
- new CFWL_PushButtonImp(properties, pOuter); |
- pPushButton->SetImpl(pPushButtonImpl); |
- pPushButtonImpl->SetInterface(pPushButton); |
- return pPushButton; |
+ return new IFWL_PushButton(properties, pOuter); |
} |
-IFWL_PushButton::IFWL_PushButton() {} |
-CFWL_PushButtonImp::CFWL_PushButtonImp( |
- const CFWL_WidgetImpProperties& properties, |
- IFWL_Widget* pOuter) |
- : CFWL_WidgetImp(properties, pOuter), |
+IFWL_PushButton::IFWL_PushButton(const CFWL_WidgetImpProperties& properties, |
+ IFWL_Widget* pOuter) |
+ : IFWL_Widget(properties, pOuter), |
m_bBtnDown(FALSE), |
m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), |
m_iTTOAlign(FDE_TTOALIGNMENT_Center) { |
@@ -39,32 +31,32 @@ CFWL_PushButtonImp::CFWL_PushButtonImp( |
m_rtCaption.Set(0, 0, 0, 0); |
} |
-CFWL_PushButtonImp::~CFWL_PushButtonImp() {} |
+IFWL_PushButton::~IFWL_PushButton() {} |
-FWL_Error CFWL_PushButtonImp::GetClassName(CFX_WideString& wsClass) const { |
+FWL_Error IFWL_PushButton::GetClassName(CFX_WideString& wsClass) const { |
wsClass = FWL_CLASS_PushButton; |
return FWL_Error::Succeeded; |
} |
-FWL_Type CFWL_PushButtonImp::GetClassID() const { |
+FWL_Type IFWL_PushButton::GetClassID() const { |
return FWL_Type::PushButton; |
} |
-FWL_Error CFWL_PushButtonImp::Initialize() { |
- if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) |
+FWL_Error IFWL_PushButton::Initialize() { |
+ if (IFWL_Widget::Initialize() != FWL_Error::Succeeded) |
return FWL_Error::Indefinite; |
m_pDelegate = new CFWL_PushButtonImpDelegate(this); |
return FWL_Error::Succeeded; |
} |
-FWL_Error CFWL_PushButtonImp::Finalize() { |
+FWL_Error IFWL_PushButton::Finalize() { |
delete m_pDelegate; |
m_pDelegate = nullptr; |
- return CFWL_WidgetImp::Finalize(); |
+ return IFWL_Widget::Finalize(); |
} |
-FWL_Error CFWL_PushButtonImp::GetWidgetRect(CFX_RectF& rect, |
- FX_BOOL bAutoSize) { |
+ |
+FWL_Error IFWL_PushButton::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
if (bAutoSize) { |
rect.Set(0, 0, 0, 0); |
if (!m_pProperties->m_pThemeProvider) { |
@@ -74,7 +66,7 @@ FWL_Error CFWL_PushButtonImp::GetWidgetRect(CFX_RectF& rect, |
IFWL_PushButtonDP* pData = |
static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider); |
if (pData) { |
- pData->GetCaption(m_pInterface, wsCaption); |
+ pData->GetCaption(this, wsCaption); |
} |
int32_t iLen = wsCaption.GetLength(); |
if (iLen > 0) { |
@@ -84,22 +76,22 @@ FWL_Error CFWL_PushButtonImp::GetWidgetRect(CFX_RectF& rect, |
FX_FLOAT* fcaption = |
static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin)); |
rect.Inflate(*fcaption, *fcaption); |
- CFWL_WidgetImp::GetWidgetRect(rect, TRUE); |
+ IFWL_Widget::GetWidgetRect(rect, TRUE); |
} else { |
rect = m_pProperties->m_rtWidget; |
} |
return FWL_Error::Succeeded; |
} |
-void CFWL_PushButtonImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { |
+void IFWL_PushButton::SetStates(uint32_t dwStates, FX_BOOL bSet) { |
if ((dwStates & FWL_WGTSTATE_Disabled) && bSet) { |
m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled; |
return; |
} |
- CFWL_WidgetImp::SetStates(dwStates, bSet); |
+ IFWL_Widget::SetStates(dwStates, bSet); |
} |
-FWL_Error CFWL_PushButtonImp::Update() { |
+FWL_Error IFWL_PushButton::Update() { |
if (IsLocked()) { |
return FWL_Error::Indefinite; |
} |
@@ -114,8 +106,9 @@ FWL_Error CFWL_PushButtonImp::Update() { |
m_rtCaption.Inflate(-*fcaption, -*fcaption); |
return FWL_Error::Succeeded; |
} |
-FWL_Error CFWL_PushButtonImp::DrawWidget(CFX_Graphics* pGraphics, |
- const CFX_Matrix* pMatrix) { |
+ |
+FWL_Error IFWL_PushButton::DrawWidget(CFX_Graphics* pGraphics, |
+ const CFX_Matrix* pMatrix) { |
if (!pGraphics) |
return FWL_Error::Indefinite; |
if (!m_pProperties->m_pThemeProvider) |
@@ -139,7 +132,7 @@ FWL_Error CFWL_PushButtonImp::DrawWidget(CFX_Graphics* pGraphics, |
FX_FLOAT ipicheight = 0; |
CFX_WideString wsCaption; |
if (pData) { |
- pData->GetCaption(m_pInterface, wsCaption); |
+ pData->GetCaption(this, wsCaption); |
} |
CFX_RectF rtText; |
rtText.Set(0, 0, 0, 0); |
@@ -152,7 +145,7 @@ FWL_Error CFWL_PushButtonImp::DrawWidget(CFX_Graphics* pGraphics, |
break; |
case FWL_STYLEEXT_PSB_IconOnly: |
if (pData) { |
- pPicture = pData->GetPicture(m_pInterface); |
+ pPicture = pData->GetPicture(this); |
} |
if (pPicture) { |
CFX_PointF point; |
@@ -302,11 +295,12 @@ FWL_Error CFWL_PushButtonImp::DrawWidget(CFX_Graphics* pGraphics, |
} |
return FWL_Error::Succeeded; |
} |
-void CFWL_PushButtonImp::DrawBkground(CFX_Graphics* pGraphics, |
- IFWL_ThemeProvider* pTheme, |
- const CFX_Matrix* pMatrix) { |
+ |
+void IFWL_PushButton::DrawBkground(CFX_Graphics* pGraphics, |
+ IFWL_ThemeProvider* pTheme, |
+ const CFX_Matrix* pMatrix) { |
CFWL_ThemeBackground param; |
- param.m_pWidget = m_pInterface; |
+ param.m_pWidget = this; |
param.m_iPart = CFWL_Part::Background; |
param.m_dwStates = GetPartStates(); |
param.m_pGraphics = pGraphics; |
@@ -319,18 +313,19 @@ void CFWL_PushButtonImp::DrawBkground(CFX_Graphics* pGraphics, |
} |
pTheme->DrawBackground(¶m); |
} |
-void CFWL_PushButtonImp::DrawText(CFX_Graphics* pGraphics, |
- IFWL_ThemeProvider* pTheme, |
- const CFX_Matrix* pMatrix) { |
+ |
+void IFWL_PushButton::DrawText(CFX_Graphics* pGraphics, |
+ IFWL_ThemeProvider* pTheme, |
+ const CFX_Matrix* pMatrix) { |
if (!m_pProperties->m_pDataProvider) |
return; |
CFX_WideString wsCaption; |
- m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); |
+ m_pProperties->m_pDataProvider->GetCaption(this, wsCaption); |
if (wsCaption.IsEmpty()) { |
return; |
} |
CFWL_ThemeText param; |
- param.m_pWidget = m_pInterface; |
+ param.m_pWidget = this; |
param.m_iPart = CFWL_Part::Caption; |
param.m_dwStates = GetPartStates(); |
param.m_pGraphics = pGraphics; |
@@ -343,7 +338,8 @@ void CFWL_PushButtonImp::DrawText(CFX_Graphics* pGraphics, |
param.m_iTTOAlign = m_iTTOAlign; |
pTheme->DrawText(¶m); |
} |
-uint32_t CFWL_PushButtonImp::GetPartStates() { |
+ |
+uint32_t IFWL_PushButton::GetPartStates() { |
uint32_t dwStates = CFWL_PartState_Normal; |
if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { |
dwStates |= CFWL_PartState_Focused; |
@@ -359,7 +355,8 @@ uint32_t CFWL_PushButtonImp::GetPartStates() { |
} |
return dwStates; |
} |
-void CFWL_PushButtonImp::UpdateTextOutStyles() { |
+ |
+void IFWL_PushButton::UpdateTextOutStyles() { |
m_iTTOAlign = FDE_TTOALIGNMENT_Center; |
switch (m_pProperties->m_dwStyleExes & |
(FWL_STYLEEXT_PSB_HLayoutMask | FWL_STYLEEXT_PSB_VLayoutMask)) { |
@@ -407,8 +404,7 @@ void CFWL_PushButtonImp::UpdateTextOutStyles() { |
} |
} |
-CFWL_PushButtonImpDelegate::CFWL_PushButtonImpDelegate( |
- CFWL_PushButtonImp* pOwner) |
+CFWL_PushButtonImpDelegate::CFWL_PushButtonImpDelegate(IFWL_PushButton* pOwner) |
: m_pOwner(pOwner) {} |
void CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
@@ -457,9 +453,7 @@ void CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
OnKeyDown(pKey); |
break; |
} |
- default: { |
- break; |
- } |
+ default: { break; } |
} |
CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); |
} |
@@ -480,6 +474,7 @@ void CFWL_PushButtonImpDelegate::OnFocusChanged(CFWL_Message* pMsg, |
} |
m_pOwner->Repaint(&m_pOwner->m_rtClient); |
} |
+ |
void CFWL_PushButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { |
if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { |
m_pOwner->SetFocus(TRUE); |
@@ -489,6 +484,7 @@ void CFWL_PushButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { |
m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed; |
m_pOwner->Repaint(&m_pOwner->m_rtClient); |
} |
+ |
void CFWL_PushButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { |
m_pOwner->m_bBtnDown = FALSE; |
if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { |
@@ -500,11 +496,12 @@ void CFWL_PushButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { |
} |
if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { |
CFWL_EvtClick wmClick; |
- wmClick.m_pSrcTarget = m_pOwner->m_pInterface; |
+ wmClick.m_pSrcTarget = m_pOwner; |
m_pOwner->DispatchEvent(&wmClick); |
} |
m_pOwner->Repaint(&m_pOwner->m_rtClient); |
} |
+ |
void CFWL_PushButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { |
FX_BOOL bRepaint = FALSE; |
if (m_pOwner->m_bBtnDown) { |
@@ -540,20 +537,22 @@ void CFWL_PushButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { |
m_pOwner->Repaint(&m_pOwner->m_rtClient); |
} |
} |
+ |
void CFWL_PushButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { |
m_pOwner->m_bBtnDown = FALSE; |
m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; |
m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; |
m_pOwner->Repaint(&m_pOwner->m_rtClient); |
} |
+ |
void CFWL_PushButtonImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { |
if (pMsg->m_dwKeyCode == FWL_VKEY_Return) { |
CFWL_EvtMouse wmMouse; |
- wmMouse.m_pSrcTarget = m_pOwner->m_pInterface; |
+ wmMouse.m_pSrcTarget = m_pOwner; |
wmMouse.m_dwCmd = FWL_MouseCommand::LeftButtonUp; |
m_pOwner->DispatchEvent(&wmMouse); |
CFWL_EvtClick wmClick; |
- wmClick.m_pSrcTarget = m_pOwner->m_pInterface; |
+ wmClick.m_pSrcTarget = m_pOwner; |
m_pOwner->DispatchEvent(&wmClick); |
return; |
} |