summaryrefslogtreecommitdiff
path: root/xfa/fxfa/app/xfa_ffcheckbutton.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/app/xfa_ffcheckbutton.cpp')
-rw-r--r--xfa/fxfa/app/xfa_ffcheckbutton.cpp75
1 files changed, 44 insertions, 31 deletions
diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp
index bc4eda0e35..9837e0aa7b 100644
--- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp
+++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp
@@ -80,20 +80,22 @@ void CXFA_FFCheckButton::UpdateWidgetProperty() {
}
} break;
}
- if (m_pDataAcc->IsAllowNeutral()) {
+ if (m_pDataAcc->IsAllowNeutral())
dwStyleEx |= FWL_STYLEEXT_CKB_3State;
- }
+
pCheckBox->ModifyStylesEx(
dwStyleEx, FWL_STYLEEXT_CKB_SignShapeMask | FWL_STYLEEXT_CKB_3State);
}
+
bool CXFA_FFCheckButton::PerformLayout() {
CXFA_FFWidget::PerformLayout();
+
float fCheckSize = m_pDataAcc->GetCheckButtonSize();
CXFA_Margin mgWidget = m_pDataAcc->GetMargin();
CFX_RectF rtWidget = GetRectWithoutRotate();
- if (mgWidget) {
+ if (mgWidget)
XFA_RectWidthoutMargin(rtWidget, mgWidget);
- }
+
int32_t iCapPlacement = -1;
float fCapReserve = 0;
CXFA_Caption caption = m_pDataAcc->GetCaption();
@@ -110,12 +112,14 @@ bool CXFA_FFCheckButton::PerformLayout() {
}
}
}
+
int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left;
int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top;
if (CXFA_Para para = m_pDataAcc->GetPara()) {
iHorzAlign = para.GetHorizontalAlign();
iVertAlign = para.GetVerticalAlign();
}
+
m_rtUI = rtWidget;
CXFA_Margin mgCap = caption.GetMargin();
switch (iCapPlacement) {
@@ -124,41 +128,46 @@ bool CXFA_FFCheckButton::PerformLayout() {
CapLeftRightPlacement(mgCap);
m_rtUI.width -= fCapReserve;
m_rtUI.left += fCapReserve;
- } break;
+ break;
+ }
case XFA_ATTRIBUTEENUM_Top: {
m_rtCaption.height = fCapReserve;
XFA_RectWidthoutMargin(m_rtCaption, mgCap);
m_rtUI.height -= fCapReserve;
m_rtUI.top += fCapReserve;
- } break;
+ break;
+ }
case XFA_ATTRIBUTEENUM_Right: {
m_rtCaption.left = m_rtCaption.right() - fCapReserve;
m_rtCaption.width = fCapReserve;
CapLeftRightPlacement(mgCap);
m_rtUI.width -= fCapReserve;
- } break;
+ break;
+ }
case XFA_ATTRIBUTEENUM_Bottom: {
m_rtCaption.top = m_rtCaption.bottom() - fCapReserve;
m_rtCaption.height = fCapReserve;
XFA_RectWidthoutMargin(m_rtCaption, mgCap);
m_rtUI.height -= fCapReserve;
- } break;
+ break;
+ }
case XFA_ATTRIBUTEENUM_Inline:
break;
default:
iHorzAlign = XFA_ATTRIBUTEENUM_Right;
break;
}
- if (iHorzAlign == XFA_ATTRIBUTEENUM_Center) {
+
+ if (iHorzAlign == XFA_ATTRIBUTEENUM_Center)
m_rtUI.left += (m_rtUI.width - fCheckSize) / 2;
- } else if (iHorzAlign == XFA_ATTRIBUTEENUM_Right) {
+ else if (iHorzAlign == XFA_ATTRIBUTEENUM_Right)
m_rtUI.left = m_rtUI.right() - fCheckSize;
- }
- if (iVertAlign == XFA_ATTRIBUTEENUM_Middle) {
+
+ if (iVertAlign == XFA_ATTRIBUTEENUM_Middle)
m_rtUI.top += (m_rtUI.height - fCheckSize) / 2;
- } else if (iVertAlign == XFA_ATTRIBUTEENUM_Bottom) {
+ else if (iVertAlign == XFA_ATTRIBUTEENUM_Bottom)
m_rtUI.top = m_rtUI.bottom() - fCheckSize;
- }
+
m_rtUI.width = fCheckSize;
m_rtUI.height = fCheckSize;
AddUIMargin(iCapPlacement);
@@ -166,31 +175,33 @@ bool CXFA_FFCheckButton::PerformLayout() {
CXFA_Border borderUI = m_pDataAcc->GetUIBorder();
if (borderUI) {
CXFA_Margin margin = borderUI.GetMargin();
- if (margin) {
+ if (margin)
XFA_RectWidthoutMargin(m_rtUI, margin);
- }
}
+
m_rtUI.Normalize();
LayoutCaption();
SetFWLRect();
- if (m_pNormalWidget) {
+ if (m_pNormalWidget)
m_pNormalWidget->Update();
- }
+
return true;
}
+
void CXFA_FFCheckButton::CapLeftRightPlacement(CXFA_Margin mgCap) {
XFA_RectWidthoutMargin(m_rtCaption, mgCap);
- if (m_rtCaption.height < 0) {
+ if (m_rtCaption.height < 0)
m_rtCaption.top += m_rtCaption.height;
- }
if (m_rtCaption.width < 0) {
m_rtCaption.left += m_rtCaption.width;
m_rtCaption.width = -m_rtCaption.width;
}
}
+
void CXFA_FFCheckButton::AddUIMargin(int32_t iCapPlacement) {
CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin();
m_rtUI.top -= rtUIMargin.top / 2 - rtUIMargin.height / 2;
+
float fLeftAddRight = rtUIMargin.left + rtUIMargin.width;
float fTopAddBottom = rtUIMargin.top + rtUIMargin.height;
if (m_rtUI.width < fLeftAddRight) {
@@ -203,13 +214,14 @@ void CXFA_FFCheckButton::AddUIMargin(int32_t iCapPlacement) {
m_rtUI.width += 2 * (fLeftAddRight - m_rtUI.width);
}
if (m_rtUI.height < fTopAddBottom) {
- if (iCapPlacement == XFA_ATTRIBUTEENUM_Right) {
+ if (iCapPlacement == XFA_ATTRIBUTEENUM_Right)
m_rtUI.left -= fTopAddBottom - m_rtUI.height;
- }
+
m_rtUI.top -= fTopAddBottom - m_rtUI.height;
m_rtUI.height += 2 * (fTopAddBottom - m_rtUI.height);
}
}
+
void CXFA_FFCheckButton::RenderWidget(CFX_Graphics* pGS,
CFX_Matrix* pMatrix,
uint32_t dwStatus) {
@@ -268,20 +280,20 @@ bool CXFA_FFCheckButton::IsDataChanged() {
XFA_CHECKSTATE eCheckState = FWLState2XFAState();
return m_pDataAcc->GetCheckState() != eCheckState;
}
+
void CXFA_FFCheckButton::SetFWLCheckState(XFA_CHECKSTATE eCheckState) {
- if (eCheckState == XFA_CHECKSTATE_Neutral) {
+ if (eCheckState == XFA_CHECKSTATE_Neutral)
m_pNormalWidget->SetStates(FWL_STATE_CKB_Neutral);
- } else {
- if (eCheckState == XFA_CHECKSTATE_On)
- m_pNormalWidget->SetStates(FWL_STATE_CKB_Checked);
- else
- m_pNormalWidget->RemoveStates(FWL_STATE_CKB_Checked);
- }
+ else if (eCheckState == XFA_CHECKSTATE_On)
+ m_pNormalWidget->SetStates(FWL_STATE_CKB_Checked);
+ else
+ m_pNormalWidget->RemoveStates(FWL_STATE_CKB_Checked);
}
+
bool CXFA_FFCheckButton::UpdateFWLData() {
- if (!m_pNormalWidget) {
+ if (!m_pNormalWidget)
return false;
- }
+
XFA_CHECKSTATE eState = m_pDataAcc->GetCheckState();
SetFWLCheckState(eState);
m_pNormalWidget->Update();
@@ -299,6 +311,7 @@ void CXFA_FFCheckButton::OnProcessEvent(CFWL_Event* pEvent) {
CXFA_EventParam eParam;
eParam.m_eType = XFA_EVENT_Change;
m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw);
+
CXFA_WidgetAcc* pFFExclGroup = m_pDataAcc->GetExclGroup();
if (ProcessCommittedData()) {
eParam.m_pTarget = pFFExclGroup;