Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Unified Diff: xfa/fwl/core/ifwl_checkbox.cpp

Issue 2432423002: Merge the CFWL_*Imp classes into the IFWL_* classes. (Closed)
Patch Set: Review feedback Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « xfa/fwl/core/ifwl_checkbox.h ('k') | xfa/fwl/core/ifwl_combobox.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fwl/core/ifwl_checkbox.cpp
diff --git a/xfa/fwl/basewidget/fwl_checkboximp.cpp b/xfa/fwl/core/ifwl_checkbox.cpp
similarity index 88%
rename from xfa/fwl/basewidget/fwl_checkboximp.cpp
rename to xfa/fwl/core/ifwl_checkbox.cpp
index 581e45319f1c53241befcd8d137ed55d61f25b7b..d822d3e8203fcd0a4ddab8b5e71c189f68ec4ad4 100644
--- a/xfa/fwl/basewidget/fwl_checkboximp.cpp
+++ b/xfa/fwl/core/ifwl_checkbox.cpp
@@ -4,18 +4,17 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fwl/basewidget/fwl_checkboximp.h"
+#include "xfa/fwl/core/ifwl_checkbox.h"
#include <algorithm>
#include "xfa/fde/tto/fde_textout.h"
-#include "xfa/fwl/basewidget/ifwl_checkbox.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/cfwl_widgetmgr.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_widgetimp.h"
+#include "xfa/fwl/core/ifwl_checkbox.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
namespace {
@@ -27,23 +26,12 @@ const int kCaptionMargin = 5;
// static
IFWL_CheckBox* IFWL_CheckBox::Create(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter) {
- IFWL_CheckBox* pCheckBox = new IFWL_CheckBox;
- CFWL_CheckBoxImp* pCheckBoxImpl = new CFWL_CheckBoxImp(properties, pOuter);
- pCheckBox->SetImpl(pCheckBoxImpl);
- pCheckBoxImpl->SetInterface(pCheckBox);
- return pCheckBox;
-}
-IFWL_CheckBox::IFWL_CheckBox() {}
-int32_t IFWL_CheckBox::GetCheckState() {
- return static_cast<CFWL_CheckBoxImp*>(GetImpl())->GetCheckState();
-}
-FWL_Error IFWL_CheckBox::SetCheckState(int32_t iCheck) {
- return static_cast<CFWL_CheckBoxImp*>(GetImpl())->SetCheckState(iCheck);
+ return new IFWL_CheckBox(properties, pOuter);
}
-CFWL_CheckBoxImp::CFWL_CheckBoxImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter)
- : CFWL_WidgetImp(properties, pOuter),
+IFWL_CheckBox::IFWL_CheckBox(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : IFWL_Widget(properties, pOuter),
m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
m_iTTOAlign(FDE_TTOALIGNMENT_Center),
m_bBtnDown(FALSE) {
@@ -53,31 +41,32 @@ CFWL_CheckBoxImp::CFWL_CheckBoxImp(const CFWL_WidgetImpProperties& properties,
m_rtFocus.Reset();
}
-CFWL_CheckBoxImp::~CFWL_CheckBoxImp() {}
+IFWL_CheckBox::~IFWL_CheckBox() {}
-FWL_Error CFWL_CheckBoxImp::GetClassName(CFX_WideString& wsClass) const {
+FWL_Error IFWL_CheckBox::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_CheckBox;
return FWL_Error::Succeeded;
}
-FWL_Type CFWL_CheckBoxImp::GetClassID() const {
+FWL_Type IFWL_CheckBox::GetClassID() const {
return FWL_Type::CheckBox;
}
-FWL_Error CFWL_CheckBoxImp::Initialize() {
- if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded)
+FWL_Error IFWL_CheckBox::Initialize() {
+ if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
return FWL_Error::Indefinite;
m_pDelegate = new CFWL_CheckBoxImpDelegate(this);
return FWL_Error::Succeeded;
}
-FWL_Error CFWL_CheckBoxImp::Finalize() {
+FWL_Error IFWL_CheckBox::Finalize() {
delete m_pDelegate;
m_pDelegate = nullptr;
- return CFWL_WidgetImp::Finalize();
+ return IFWL_Widget::Finalize();
}
-FWL_Error CFWL_CheckBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+
+FWL_Error IFWL_CheckBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Set(0, 0, 0, 0);
if (!m_pProperties->m_pThemeProvider)
@@ -87,7 +76,7 @@ FWL_Error CFWL_CheckBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (!m_pProperties->m_pDataProvider)
return FWL_Error::Indefinite;
CFX_WideString wsCaption;
- m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption);
+ m_pProperties->m_pDataProvider->GetCaption(this, wsCaption);
if (wsCaption.GetLength() > 0) {
CFX_SizeF sz = CalcTextSize(
wsCaption, m_pProperties->m_pThemeProvider,
@@ -97,18 +86,19 @@ FWL_Error CFWL_CheckBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
rect.Inflate(kCaptionMargin, kCaptionMargin);
IFWL_CheckBoxDP* pData =
static_cast<IFWL_CheckBoxDP*>(m_pProperties->m_pDataProvider);
- FX_FLOAT fCheckBox = pData->GetBoxSize(m_pInterface);
+ FX_FLOAT fCheckBox = pData->GetBoxSize(this);
rect.width += fCheckBox;
if (rect.height < fCheckBox) {
rect.height = fCheckBox;
}
- CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
+ IFWL_Widget::GetWidgetRect(rect, TRUE);
} else {
rect = m_pProperties->m_rtWidget;
}
return FWL_Error::Succeeded;
}
-FWL_Error CFWL_CheckBoxImp::Update() {
+
+FWL_Error IFWL_CheckBox::Update() {
if (IsLocked()) {
return FWL_Error::Indefinite;
}
@@ -119,8 +109,9 @@ FWL_Error CFWL_CheckBoxImp::Update() {
Layout();
return FWL_Error::Succeeded;
}
-FWL_Error CFWL_CheckBoxImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+
+FWL_Error IFWL_CheckBox::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (!pGraphics)
return FWL_Error::Indefinite;
if (!m_pProperties->m_pThemeProvider)
@@ -136,7 +127,7 @@ FWL_Error CFWL_CheckBoxImp::DrawWidget(CFX_Graphics* pGraphics,
int32_t dwStates = GetPartStates();
{
CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
+ param.m_pWidget = this;
param.m_iPart = CFWL_Part::Background;
param.m_dwStates = dwStates;
param.m_pGraphics = pGraphics;
@@ -156,12 +147,12 @@ FWL_Error CFWL_CheckBoxImp::DrawWidget(CFX_Graphics* pGraphics,
return FWL_Error::Indefinite;
{
CFX_WideString wsCaption;
- m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption);
+ m_pProperties->m_pDataProvider->GetCaption(this, wsCaption);
int32_t iLen = wsCaption.GetLength();
if (iLen <= 0)
return FWL_Error::Indefinite;
CFWL_ThemeText textParam;
- textParam.m_pWidget = m_pInterface;
+ textParam.m_pWidget = this;
textParam.m_iPart = CFWL_Part::Caption;
textParam.m_dwStates = dwStates;
textParam.m_pGraphics = pGraphics;
@@ -176,7 +167,8 @@ FWL_Error CFWL_CheckBoxImp::DrawWidget(CFX_Graphics* pGraphics,
}
return FWL_Error::Succeeded;
}
-int32_t CFWL_CheckBoxImp::GetCheckState() {
+
+int32_t IFWL_CheckBox::GetCheckState() {
if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) &&
((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
FWL_STATE_CKB_Neutral)) {
@@ -188,7 +180,8 @@ int32_t CFWL_CheckBoxImp::GetCheckState() {
}
return 0;
}
-FWL_Error CFWL_CheckBoxImp::SetCheckState(int32_t iCheck) {
+
+FWL_Error IFWL_CheckBox::SetCheckState(int32_t iCheck) {
m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask;
switch (iCheck) {
case 0: {
@@ -209,7 +202,8 @@ FWL_Error CFWL_CheckBoxImp::SetCheckState(int32_t iCheck) {
Repaint(&m_rtClient);
return FWL_Error::Succeeded;
}
-void CFWL_CheckBoxImp::Layout() {
+
+void IFWL_CheckBox::Layout() {
int32_t width = int32_t(m_pProperties->m_rtWidget.width + 0.5f);
int32_t height = int32_t(m_pProperties->m_rtWidget.height + 0.5f);
m_pProperties->m_rtWidget.width = (FX_FLOAT)width;
@@ -224,7 +218,7 @@ void CFWL_CheckBoxImp::Layout() {
return;
IFWL_CheckBoxDP* pData =
static_cast<IFWL_CheckBoxDP*>(m_pProperties->m_pDataProvider);
- FX_FLOAT fCheckBox = pData->GetBoxSize(m_pInterface);
+ FX_FLOAT fCheckBox = pData->GetBoxSize(this);
switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) {
case FWL_STYLEEXT_CKB_Top: {
fBoxTop = m_rtClient.top;
@@ -256,7 +250,7 @@ void CFWL_CheckBoxImp::Layout() {
rtFocus.Set(m_rtCaption.left, m_rtCaption.top, m_rtCaption.width,
m_rtCaption.height);
CFX_WideString wsCaption;
- m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption);
+ m_pProperties->m_pDataProvider->GetCaption(this, wsCaption);
if (wsCaption.IsEmpty()) {
m_rtFocus.Set(0, 0, 0, 0);
} else {
@@ -288,7 +282,8 @@ void CFWL_CheckBoxImp::Layout() {
m_rtFocus.Inflate(1, 1);
}
}
-uint32_t CFWL_CheckBoxImp::GetPartStates() {
+
+uint32_t IFWL_CheckBox::GetPartStates() {
int32_t dwStates = CFWL_PartState_Normal;
if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
FWL_STATE_CKB_Neutral) {
@@ -311,7 +306,8 @@ uint32_t CFWL_CheckBoxImp::GetPartStates() {
}
return dwStates;
}
-void CFWL_CheckBoxImp::UpdateTextOutStyles() {
+
+void IFWL_CheckBox::UpdateTextOutStyles() {
m_iTTOAlign = FDE_TTOALIGNMENT_Center;
switch (m_pProperties->m_dwStyleExes &
(FWL_STYLEEXT_CKB_HLayoutMask | FWL_STYLEEXT_CKB_VLayoutMask)) {
@@ -363,7 +359,8 @@ void CFWL_CheckBoxImp::UpdateTextOutStyles() {
m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine;
}
}
-void CFWL_CheckBoxImp::NextStates() {
+
+void IFWL_CheckBox::NextStates() {
uint32_t dwFirststate = m_pProperties->m_dwStates;
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton) {
if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
@@ -371,12 +368,12 @@ void CFWL_CheckBoxImp::NextStates() {
CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
if (!pWidgetMgr->IsFormDisabled()) {
CFX_ArrayTemplate<IFWL_Widget*> radioarr;
- pWidgetMgr->GetSameGroupRadioButton(m_pInterface, radioarr);
+ pWidgetMgr->GetSameGroupRadioButton(this, radioarr);
IFWL_CheckBox* pCheckBox = nullptr;
int32_t iCount = radioarr.GetSize();
for (int32_t i = 0; i < iCount; i++) {
pCheckBox = static_cast<IFWL_CheckBox*>(radioarr[i]);
- if (pCheckBox != m_pInterface &&
+ if (pCheckBox != this &&
pCheckBox->GetStates() & FWL_STATE_CKB_Checked) {
pCheckBox->SetCheckState(0);
CFX_RectF rt;
@@ -411,11 +408,12 @@ void CFWL_CheckBoxImp::NextStates() {
uint32_t dwLaststate = m_pProperties->m_dwStates;
if (dwFirststate != dwLaststate) {
CFWL_EvtCkbCheckStateChanged wmCheckBoxState;
- wmCheckBoxState.m_pSrcTarget = m_pInterface;
+ wmCheckBoxState.m_pSrcTarget = this;
DispatchEvent(&wmCheckBoxState);
}
}
-CFWL_CheckBoxImpDelegate::CFWL_CheckBoxImpDelegate(CFWL_CheckBoxImp* pOwner)
+
+CFWL_CheckBoxImpDelegate::CFWL_CheckBoxImpDelegate(IFWL_CheckBox* pOwner)
: m_pOwner(pOwner) {}
void CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
@@ -465,9 +463,7 @@ void CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
OnKeyDown(pKey);
break;
}
- default: {
- break;
- }
+ default: { break; }
}
CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
@@ -482,6 +478,7 @@ void CFWL_CheckBoxImpDelegate::OnActivate(CFWL_Message* pMsg) {
m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
m_pOwner->Repaint(&(m_pOwner->m_rtClient));
}
+
void CFWL_CheckBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
FX_BOOL bSet) {
if (bSet) {
@@ -491,6 +488,7 @@ void CFWL_CheckBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
}
m_pOwner->Repaint(&(m_pOwner->m_rtClient));
}
+
void CFWL_CheckBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
return;
@@ -503,6 +501,7 @@ void CFWL_CheckBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed;
m_pOwner->Repaint(&(m_pOwner->m_rtClient));
}
+
void CFWL_CheckBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
if (!m_pOwner->m_bBtnDown) {
return;
@@ -515,6 +514,7 @@ void CFWL_CheckBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Pressed;
m_pOwner->NextStates();
}
+
void CFWL_CheckBoxImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
return;
@@ -552,6 +552,7 @@ void CFWL_CheckBoxImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
m_pOwner->Repaint(&(m_pOwner->m_rtBox));
}
}
+
void CFWL_CheckBoxImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
if (m_pOwner->m_bBtnDown) {
m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
@@ -560,6 +561,7 @@ void CFWL_CheckBoxImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
}
m_pOwner->Repaint(&(m_pOwner->m_rtBox));
}
+
void CFWL_CheckBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) {
m_pOwner->DispatchKeyEvent(pMsg);
« no previous file with comments | « xfa/fwl/core/ifwl_checkbox.h ('k') | xfa/fwl/core/ifwl_combobox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698