summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-05-11 20:45:26 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-11 20:45:26 +0000
commit9201cec90704612c05ad4a850b7a70c277c415aa (patch)
tree762b0fdd5f421cc0454b5928273cfcdfd4394139 /xfa
parent466bd4f4e0cb2bc2a7b3626948609268c52c4690 (diff)
downloadpdfium-9201cec90704612c05ad4a850b7a70c277c415aa.tar.xz
Inline Disform_* methods.
The non-Disform versions are gone, so inline the Disform_ versions to reduce indirection. Change-Id: Icf261795e5df6e5015055ec64f3dcdba56789a07 Reviewed-on: https://pdfium-review.googlesource.com/32373 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fwl/cfwl_combobox.cpp271
-rw-r--r--xfa/fwl/cfwl_combobox.h11
-rw-r--r--xfa/fwl/cfwl_datetimeedit.cpp4
-rw-r--r--xfa/fwl/cfwl_datetimeedit.h3
-rw-r--r--xfa/fwl/cfwl_datetimepicker.cpp279
-rw-r--r--xfa/fwl/cfwl_datetimepicker.h9
-rw-r--r--xfa/fwl/cfwl_monthcalendar.cpp4
-rw-r--r--xfa/fwl/cfwl_monthcalendar.h1
8 files changed, 248 insertions, 334 deletions
diff --git a/xfa/fwl/cfwl_combobox.cpp b/xfa/fwl/cfwl_combobox.cpp
index c60c27497f..d53a9e4aea 100644
--- a/xfa/fwl/cfwl_combobox.cpp
+++ b/xfa/fwl/cfwl_combobox.cpp
@@ -40,8 +40,8 @@ CFWL_ComboBox::CFWL_ComboBox(const CFWL_App* app)
m_rtBtn.Reset();
m_rtHandler.Reset();
- DisForm_InitComboList();
- DisForm_InitComboEdit();
+ InitComboList();
+ InitComboEdit();
}
CFWL_ComboBox::~CFWL_ComboBox() {}
@@ -64,15 +64,44 @@ void CFWL_ComboBox::RemoveAll() {
void CFWL_ComboBox::ModifyStylesEx(uint32_t dwStylesExAdded,
uint32_t dwStylesExRemoved) {
- DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
+ if (!m_pEdit)
+ InitComboEdit();
+
+ bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown);
+ bool bDelDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown);
+
+ dwStylesExRemoved &= ~FWL_STYLEEXT_CMB_DropDown;
+ m_pProperties->m_dwStyleExes |= FWL_STYLEEXT_CMB_DropDown;
+
+ if (bAddDropDown)
+ m_pEdit->ModifyStylesEx(0, FWL_STYLEEXT_EDT_ReadOnly);
+ else if (bDelDropDown)
+ m_pEdit->ModifyStylesEx(FWL_STYLEEXT_EDT_ReadOnly, 0);
+ CFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
}
void CFWL_ComboBox::Update() {
- DisForm_Update();
+ if (m_iLock)
+ return;
+ if (m_pEdit)
+ ResetEditAlignment();
+ ResetTheme();
+ Layout();
}
FWL_WidgetHit CFWL_ComboBox::HitTest(const CFX_PointF& point) {
- return DisForm_HitTest(point);
+ CFX_RectF rect(0, 0, m_pProperties->m_rtWidget.width - m_rtBtn.width,
+ m_pProperties->m_rtWidget.height);
+ if (rect.Contains(point))
+ return FWL_WidgetHit::Edit;
+ if (m_rtBtn.Contains(point))
+ return FWL_WidgetHit::Client;
+ if (DisForm_IsDropListVisible()) {
+ rect = m_pListBox->GetWidgetRect();
+ if (rect.Contains(point))
+ return FWL_WidgetHit::Client;
+ }
+ return FWL_WidgetHit::Unknown;
}
void CFWL_ComboBox::DrawWidget(CXFA_Graphics* pGraphics,
@@ -151,7 +180,14 @@ void CFWL_ComboBox::OpenDropDownList(bool bActivate) {
}
CFX_RectF CFWL_ComboBox::GetBBox() const {
- return DisForm_GetBBox();
+ CFX_RectF rect = m_pProperties->m_rtWidget;
+ if (!m_pListBox || !DisForm_IsDropListVisible())
+ return rect;
+
+ CFX_RectF rtList = m_pListBox->GetWidgetRect();
+ rtList.Offset(rect.left, rect.top);
+ rect.Union(rtList);
+ return rect;
}
void CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded,
@@ -174,7 +210,48 @@ void CFWL_ComboBox::DrawStretchHandler(CXFA_Graphics* pGraphics,
}
void CFWL_ComboBox::ShowDropList(bool bActivate) {
- return DisForm_ShowDropList(bActivate);
+ if (DisForm_IsDropListVisible() == bActivate)
+ return;
+
+ if (bActivate) {
+ CFWL_Event preEvent(CFWL_Event::Type::PreDropDown, this);
+ DispatchEvent(&preEvent);
+
+ CFWL_ComboList* pComboList = m_pListBox.get();
+ int32_t iItems = pComboList->CountItems(nullptr);
+ if (iItems < 1)
+ return;
+
+ ResetListItemAlignment();
+ pComboList->ChangeSelected(m_iCurSel);
+
+ float fItemHeight = pComboList->CalcItemHeight();
+ float fBorder = GetBorderSize(true);
+ float fPopupMin = 0.0f;
+ if (iItems > 3)
+ fPopupMin = fItemHeight * 3 + fBorder * 2;
+
+ float fPopupMax = fItemHeight * iItems + fBorder * 2;
+ CFX_RectF rtList(m_rtClient.left, 0, m_pProperties->m_rtWidget.width, 0);
+ GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, &rtList);
+
+ m_pListBox->SetWidgetRect(rtList);
+ m_pListBox->Update();
+ } else {
+ SetFocus(true);
+ }
+
+ if (bActivate) {
+ m_pListBox->RemoveStates(FWL_WGTSTATE_Invisible);
+ CFWL_Event postEvent(CFWL_Event::Type::PostDropDown, this);
+ DispatchEvent(&postEvent);
+ } else {
+ m_pListBox->SetStates(FWL_WGTSTATE_Invisible);
+ }
+
+ CFX_RectF rect = m_pListBox->GetWidgetRect();
+ rect.Inflate(2, 2);
+ RepaintRect(rect);
}
void CFWL_ComboBox::MatchEditText() {
@@ -198,7 +275,40 @@ void CFWL_ComboBox::SyncEditText(int32_t iListItem) {
}
void CFWL_ComboBox::Layout() {
- return DisForm_Layout();
+ m_rtClient = GetClientRect();
+ m_rtContent = m_rtClient;
+ IFWL_ThemeProvider* theme = GetAvailableTheme();
+ if (!theme)
+ return;
+
+ float borderWidth = 1;
+ float fBtn = theme->GetScrollBarWidth();
+ if (!(GetStylesEx() & FWL_STYLEEXT_CMB_ReadOnly)) {
+ m_rtBtn =
+ CFX_RectF(m_rtClient.right() - fBtn, m_rtClient.top + borderWidth,
+ fBtn - borderWidth, m_rtClient.height - 2 * borderWidth);
+ }
+
+ CFWL_ThemePart part;
+ part.m_pWidget = this;
+ CFX_RectF pUIMargin = theme->GetUIMargin(&part);
+ m_rtContent.Deflate(pUIMargin.left, pUIMargin.top, pUIMargin.width,
+ pUIMargin.height);
+
+ if (!IsDropDownStyle() || !m_pEdit)
+ return;
+
+ CFX_RectF rtEdit(m_rtContent.left, m_rtContent.top, m_rtContent.width - fBtn,
+ m_rtContent.height);
+ m_pEdit->SetWidgetRect(rtEdit);
+
+ if (m_iCurSel >= 0) {
+ CFWL_ListItem* hItem = m_pListBox->GetItem(this, m_iCurSel);
+ m_pEdit->LockUpdate();
+ m_pEdit->SetText(hItem ? hItem->GetText() : L"");
+ m_pEdit->UnlockUpdate();
+ }
+ m_pEdit->Update();
}
void CFWL_ComboBox::ResetTheme() {
@@ -307,7 +417,7 @@ void CFWL_ComboBox::InitProxyForm() {
m_pListBox->SetParent(m_pComboBoxProxy);
}
-void CFWL_ComboBox::DisForm_InitComboList() {
+void CFWL_ComboBox::InitComboList() {
if (m_pListBox)
return;
@@ -320,7 +430,7 @@ void CFWL_ComboBox::DisForm_InitComboList() {
std::move(prop), this);
}
-void CFWL_ComboBox::DisForm_InitComboEdit() {
+void CFWL_ComboBox::InitComboEdit() {
if (m_pEdit)
return;
@@ -333,93 +443,6 @@ void CFWL_ComboBox::DisForm_InitComboEdit() {
m_pEdit->SetOuter(this);
}
-void CFWL_ComboBox::DisForm_ShowDropList(bool bActivate) {
- if (DisForm_IsDropListVisible() == bActivate)
- return;
-
- if (bActivate) {
- CFWL_Event preEvent(CFWL_Event::Type::PreDropDown, this);
- DispatchEvent(&preEvent);
-
- CFWL_ComboList* pComboList = m_pListBox.get();
- int32_t iItems = pComboList->CountItems(nullptr);
- if (iItems < 1)
- return;
-
- ResetListItemAlignment();
- pComboList->ChangeSelected(m_iCurSel);
-
- float fItemHeight = pComboList->CalcItemHeight();
- float fBorder = GetBorderSize(true);
- float fPopupMin = 0.0f;
- if (iItems > 3)
- fPopupMin = fItemHeight * 3 + fBorder * 2;
-
- float fPopupMax = fItemHeight * iItems + fBorder * 2;
- CFX_RectF rtList(m_rtClient.left, 0, m_pProperties->m_rtWidget.width, 0);
- GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, &rtList);
-
- m_pListBox->SetWidgetRect(rtList);
- m_pListBox->Update();
- } else {
- SetFocus(true);
- }
-
- if (bActivate) {
- m_pListBox->RemoveStates(FWL_WGTSTATE_Invisible);
- CFWL_Event postEvent(CFWL_Event::Type::PostDropDown, this);
- DispatchEvent(&postEvent);
- } else {
- m_pListBox->SetStates(FWL_WGTSTATE_Invisible);
- }
-
- CFX_RectF rect = m_pListBox->GetWidgetRect();
- rect.Inflate(2, 2);
- RepaintRect(rect);
-}
-
-void CFWL_ComboBox::DisForm_ModifyStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved) {
- if (!m_pEdit)
- DisForm_InitComboEdit();
-
- bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown);
- bool bDelDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown);
-
- dwStylesExRemoved &= ~FWL_STYLEEXT_CMB_DropDown;
- m_pProperties->m_dwStyleExes |= FWL_STYLEEXT_CMB_DropDown;
-
- if (bAddDropDown)
- m_pEdit->ModifyStylesEx(0, FWL_STYLEEXT_EDT_ReadOnly);
- else if (bDelDropDown)
- m_pEdit->ModifyStylesEx(FWL_STYLEEXT_EDT_ReadOnly, 0);
- CFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
-}
-
-void CFWL_ComboBox::DisForm_Update() {
- if (m_iLock)
- return;
- if (m_pEdit)
- ResetEditAlignment();
- ResetTheme();
- Layout();
-}
-
-FWL_WidgetHit CFWL_ComboBox::DisForm_HitTest(const CFX_PointF& point) {
- CFX_RectF rect(0, 0, m_pProperties->m_rtWidget.width - m_rtBtn.width,
- m_pProperties->m_rtWidget.height);
- if (rect.Contains(point))
- return FWL_WidgetHit::Edit;
- if (m_rtBtn.Contains(point))
- return FWL_WidgetHit::Client;
- if (DisForm_IsDropListVisible()) {
- rect = m_pListBox->GetWidgetRect();
- if (rect.Contains(point))
- return FWL_WidgetHit::Client;
- }
- return FWL_WidgetHit::Unknown;
-}
-
void CFWL_ComboBox::DisForm_DrawWidget(CXFA_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
@@ -454,54 +477,6 @@ void CFWL_ComboBox::DisForm_DrawWidget(CXFA_Graphics* pGraphics,
}
}
-CFX_RectF CFWL_ComboBox::DisForm_GetBBox() const {
- CFX_RectF rect = m_pProperties->m_rtWidget;
- if (!m_pListBox || !DisForm_IsDropListVisible())
- return rect;
-
- CFX_RectF rtList = m_pListBox->GetWidgetRect();
- rtList.Offset(rect.left, rect.top);
- rect.Union(rtList);
- return rect;
-}
-
-void CFWL_ComboBox::DisForm_Layout() {
- m_rtClient = GetClientRect();
- m_rtContent = m_rtClient;
- IFWL_ThemeProvider* theme = GetAvailableTheme();
- if (!theme)
- return;
-
- float borderWidth = 1;
- float fBtn = theme->GetScrollBarWidth();
- if (!(GetStylesEx() & FWL_STYLEEXT_CMB_ReadOnly)) {
- m_rtBtn =
- CFX_RectF(m_rtClient.right() - fBtn, m_rtClient.top + borderWidth,
- fBtn - borderWidth, m_rtClient.height - 2 * borderWidth);
- }
-
- CFWL_ThemePart part;
- part.m_pWidget = this;
- CFX_RectF pUIMargin = theme->GetUIMargin(&part);
- m_rtContent.Deflate(pUIMargin.left, pUIMargin.top, pUIMargin.width,
- pUIMargin.height);
-
- if (!IsDropDownStyle() || !m_pEdit)
- return;
-
- CFX_RectF rtEdit(m_rtContent.left, m_rtContent.top, m_rtContent.width - fBtn,
- m_rtContent.height);
- m_pEdit->SetWidgetRect(rtEdit);
-
- if (m_iCurSel >= 0) {
- CFWL_ListItem* hItem = m_pListBox->GetItem(this, m_iCurSel);
- m_pEdit->LockUpdate();
- m_pEdit->SetText(hItem ? hItem->GetText() : L"");
- m_pEdit->UnlockUpdate();
- }
- m_pEdit->Update();
-}
-
void CFWL_ComboBox::OnProcessMessage(CFWL_Message* pMessage) {
DisForm_OnProcessMessage(pMessage);
}
@@ -719,12 +694,12 @@ void CFWL_ComboBox::DisForm_OnLButtonDown(CFWL_MessageMouse* pMsg) {
return;
if (DisForm_IsDropListVisible()) {
- DisForm_ShowDropList(false);
+ ShowDropList(false);
return;
}
if (m_pEdit)
MatchEditText();
- DisForm_ShowDropList(true);
+ ShowDropList(true);
}
void CFWL_ComboBox::DisForm_OnFocusChanged(CFWL_Message* pMsg, bool bSet) {
@@ -736,7 +711,7 @@ void CFWL_ComboBox::DisForm_OnFocusChanged(CFWL_Message* pMsg, bool bSet) {
}
} else {
m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- DisForm_ShowDropList(false);
+ ShowDropList(false);
CFWL_MessageKillFocus msg(m_pEdit.get());
m_pEdit->GetDelegate()->OnProcessMessage(&msg);
}
diff --git a/xfa/fwl/cfwl_combobox.h b/xfa/fwl/cfwl_combobox.h
index bd8cd056eb..0f05f75650 100644
--- a/xfa/fwl/cfwl_combobox.h
+++ b/xfa/fwl/cfwl_combobox.h
@@ -129,19 +129,12 @@ class CFWL_ComboBox : public CFWL_Widget {
void OnKey(CFWL_MessageKey* pMsg);
void DoSubCtrlKey(CFWL_MessageKey* pMsg);
- void DisForm_InitComboList();
- void DisForm_InitComboEdit();
- void DisForm_ShowDropList(bool bActivate);
+ void InitComboList();
+ void InitComboEdit();
bool DisForm_IsDropListVisible() const {
return !(m_pListBox->GetStates() & FWL_WGTSTATE_Invisible);
}
- void DisForm_ModifyStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved);
- void DisForm_Update();
- FWL_WidgetHit DisForm_HitTest(const CFX_PointF& point);
void DisForm_DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix);
- CFX_RectF DisForm_GetBBox() const;
- void DisForm_Layout();
void DisForm_OnProcessMessage(CFWL_Message* pMessage);
void DisForm_OnLButtonDown(CFWL_MessageMouse* pMsg);
void DisForm_OnFocusChanged(CFWL_Message* pMsg, bool bSet);
diff --git a/xfa/fwl/cfwl_datetimeedit.cpp b/xfa/fwl/cfwl_datetimeedit.cpp
index ae7cd1ed96..ceb30c7a17 100644
--- a/xfa/fwl/cfwl_datetimeedit.cpp
+++ b/xfa/fwl/cfwl_datetimeedit.cpp
@@ -21,10 +21,6 @@ CFWL_DateTimeEdit::CFWL_DateTimeEdit(
: CFWL_Edit(app, std::move(properties), pOuter) {}
void CFWL_DateTimeEdit::OnProcessMessage(CFWL_Message* pMessage) {
- DisForm_OnProcessMessage(pMessage);
-}
-
-void CFWL_DateTimeEdit::DisForm_OnProcessMessage(CFWL_Message* pMessage) {
if (pMessage->GetType() != CFWL_Message::Type::Mouse) {
CFWL_Edit::OnProcessMessage(pMessage);
return;
diff --git a/xfa/fwl/cfwl_datetimeedit.h b/xfa/fwl/cfwl_datetimeedit.h
index 923ad05c90..dcbebd2027 100644
--- a/xfa/fwl/cfwl_datetimeedit.h
+++ b/xfa/fwl/cfwl_datetimeedit.h
@@ -21,9 +21,6 @@ class CFWL_DateTimeEdit : public CFWL_Edit {
// CFWL_Edit.
void OnProcessMessage(CFWL_Message* pMessage) override;
-
- private:
- void DisForm_OnProcessMessage(CFWL_Message* pMessage);
};
#endif // XFA_FWL_CFWL_DATETIMEEDIT_H_
diff --git a/xfa/fwl/cfwl_datetimepicker.cpp b/xfa/fwl/cfwl_datetimepicker.cpp
index 94d1d939b8..f7492295a9 100644
--- a/xfa/fwl/cfwl_datetimepicker.cpp
+++ b/xfa/fwl/cfwl_datetimepicker.cpp
@@ -64,11 +64,46 @@ FWL_Type CFWL_DateTimePicker::GetClassID() const {
}
void CFWL_DateTimePicker::Update() {
- DisForm_Update();
+ if (m_iLock)
+ return;
+ if (!m_pProperties->m_pThemeProvider)
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+
+ m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider);
+ m_rtClient = GetClientRect();
+ m_pEdit->SetWidgetRect(m_rtClient);
+ ResetEditAlignment();
+ m_pEdit->Update();
+
+ if (!m_pMonthCal->GetThemeProvider())
+ m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider);
+
+ IFWL_ThemeProvider* theme = GetAvailableTheme();
+ if (!theme)
+ return;
+
+ m_fBtn = theme->GetScrollBarWidth();
+ CFX_RectF rtMonthCal = m_pMonthCal->GetAutosizedWidgetRect();
+ CFX_RectF rtPopUp(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight,
+ rtMonthCal.width, rtMonthCal.height);
+ m_pMonthCal->SetWidgetRect(rtPopUp);
+ m_pMonthCal->Update();
}
FWL_WidgetHit CFWL_DateTimePicker::HitTest(const CFX_PointF& point) {
- return DisForm_HitTest(point);
+ CFX_RectF rect(0, 0, m_pProperties->m_rtWidget.width,
+ m_pProperties->m_rtWidget.height);
+ if (rect.Contains(point))
+ return FWL_WidgetHit::Edit;
+ if (NeedsToShowButton())
+ rect.width += m_fBtn;
+ if (rect.Contains(point))
+ return FWL_WidgetHit::Client;
+ if (IsMonthCalendarVisible()) {
+ if (m_pMonthCal->GetWidgetRect().Contains(point))
+ return FWL_WidgetHit::Client;
+ }
+ return FWL_WidgetHit::Unknown;
}
void CFWL_DateTimePicker::DrawWidget(CXFA_Graphics* pGraphics,
@@ -83,7 +118,21 @@ void CFWL_DateTimePicker::DrawWidget(CXFA_Graphics* pGraphics,
DrawBorder(pGraphics, CFWL_Part::Border, pTheme, matrix);
if (!m_rtBtn.IsEmpty())
DrawDropDownButton(pGraphics, pTheme, &matrix);
- DisForm_DrawWidget(pGraphics, &matrix);
+
+ if (m_pEdit) {
+ CFX_RectF rtEdit = m_pEdit->GetWidgetRect();
+
+ CFX_Matrix mt(1, 0, 0, 1, rtEdit.left, rtEdit.top);
+ mt.Concat(matrix);
+ m_pEdit->DrawWidget(pGraphics, mt);
+ }
+ if (!IsMonthCalendarVisible())
+ return;
+
+ CFX_RectF rtMonth = m_pMonthCal->GetWidgetRect();
+ CFX_Matrix mt(1, 0, 0, 1, rtMonth.left, rtMonth.top);
+ mt.Concat(matrix);
+ m_pMonthCal->DrawWidget(pGraphics, mt);
}
void CFWL_DateTimePicker::SetThemeProvider(IFWL_ThemeProvider* pTP) {
@@ -131,7 +180,16 @@ WideString CFWL_DateTimePicker::GetEditText() const {
}
CFX_RectF CFWL_DateTimePicker::GetBBox() const {
- return DisForm_GetBBox();
+ CFX_RectF rect = m_pProperties->m_rtWidget;
+ if (NeedsToShowButton())
+ rect.width += m_fBtn;
+ if (!IsMonthCalendarVisible())
+ return rect;
+
+ CFX_RectF rtMonth = m_pMonthCal->GetWidgetRect();
+ rtMonth.Offset(m_pProperties->m_rtWidget.left, m_pProperties->m_rtWidget.top);
+ rect.Union(rtMonth);
+ return rect;
}
void CFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded,
@@ -170,11 +228,44 @@ WideString CFWL_DateTimePicker::FormatDateString(int32_t iYear,
}
void CFWL_DateTimePicker::ShowMonthCalendar(bool bActivate) {
- return DisForm_ShowMonthCalendar(bActivate);
+ if (IsMonthCalendarVisible() == bActivate)
+ return;
+
+ if (bActivate) {
+ CFX_RectF rtMonthCal = m_pMonthCal->GetAutosizedWidgetRect();
+ float fPopupMin = rtMonthCal.height;
+ float fPopupMax = rtMonthCal.height;
+ CFX_RectF rtAnchor(m_pProperties->m_rtWidget);
+ rtAnchor.width = rtMonthCal.width;
+ rtMonthCal.left = m_rtClient.left;
+ rtMonthCal.top = rtAnchor.Height();
+ GetPopupPos(fPopupMin, fPopupMax, rtAnchor, &rtMonthCal);
+ m_pMonthCal->SetWidgetRect(rtMonthCal);
+ if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0)
+ m_pMonthCal->SetSelect(m_iYear, m_iMonth, m_iDay);
+ m_pMonthCal->Update();
+ }
+ if (bActivate)
+ m_pMonthCal->RemoveStates(FWL_WGTSTATE_Invisible);
+ else
+ m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible);
+
+ if (bActivate) {
+ CFWL_MessageSetFocus msg(m_pEdit.get(), m_pMonthCal.get());
+ m_pEdit->GetDelegate()->OnProcessMessage(&msg);
+ }
+
+ CFX_RectF rtInvalidate(0, 0, m_pProperties->m_rtWidget.width,
+ m_pProperties->m_rtWidget.height);
+
+ CFX_RectF rtCal = m_pMonthCal->GetWidgetRect();
+ rtInvalidate.Union(rtCal);
+ rtInvalidate.Inflate(2, 2);
+ RepaintRect(rtInvalidate);
}
bool CFWL_DateTimePicker::IsMonthCalendarVisible() const {
- return DisForm_IsMonthCalendarVisible();
+ return (m_pMonthCal && !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible));
}
void CFWL_DateTimePicker::ResetEditAlignment() {
@@ -253,134 +344,12 @@ void CFWL_DateTimePicker::InitProxyForm() {
m_pMonthCal->SetParent(m_pForm.get());
}
-bool CFWL_DateTimePicker::DisForm_IsMonthCalendarVisible() const {
- if (!m_pMonthCal)
- return false;
- return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible);
-}
-
-void CFWL_DateTimePicker::DisForm_ShowMonthCalendar(bool bActivate) {
- if (IsMonthCalendarVisible() == bActivate)
- return;
-
- if (bActivate) {
- CFX_RectF rtMonthCal = m_pMonthCal->GetAutosizedWidgetRect();
- float fPopupMin = rtMonthCal.height;
- float fPopupMax = rtMonthCal.height;
- CFX_RectF rtAnchor(m_pProperties->m_rtWidget);
- rtAnchor.width = rtMonthCal.width;
- rtMonthCal.left = m_rtClient.left;
- rtMonthCal.top = rtAnchor.Height();
- GetPopupPos(fPopupMin, fPopupMax, rtAnchor, &rtMonthCal);
- m_pMonthCal->SetWidgetRect(rtMonthCal);
- if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0)
- m_pMonthCal->SetSelect(m_iYear, m_iMonth, m_iDay);
- m_pMonthCal->Update();
- }
- if (bActivate)
- m_pMonthCal->RemoveStates(FWL_WGTSTATE_Invisible);
- else
- m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible);
-
- if (bActivate) {
- CFWL_MessageSetFocus msg(m_pEdit.get(), m_pMonthCal.get());
- m_pEdit->GetDelegate()->OnProcessMessage(&msg);
- }
-
- CFX_RectF rtInvalidate(0, 0, m_pProperties->m_rtWidget.width,
- m_pProperties->m_rtWidget.height);
-
- CFX_RectF rtCal = m_pMonthCal->GetWidgetRect();
- rtInvalidate.Union(rtCal);
- rtInvalidate.Inflate(2, 2);
- RepaintRect(rtInvalidate);
-}
-
-FWL_WidgetHit CFWL_DateTimePicker::DisForm_HitTest(
- const CFX_PointF& point) const {
- CFX_RectF rect(0, 0, m_pProperties->m_rtWidget.width,
- m_pProperties->m_rtWidget.height);
- if (rect.Contains(point))
- return FWL_WidgetHit::Edit;
- if (DisForm_IsNeedShowButton())
- rect.width += m_fBtn;
- if (rect.Contains(point))
- return FWL_WidgetHit::Client;
- if (IsMonthCalendarVisible()) {
- if (m_pMonthCal->GetWidgetRect().Contains(point))
- return FWL_WidgetHit::Client;
- }
- return FWL_WidgetHit::Unknown;
-}
-
-bool CFWL_DateTimePicker::DisForm_IsNeedShowButton() const {
+bool CFWL_DateTimePicker::NeedsToShowButton() const {
return m_pProperties->m_dwStates & FWL_WGTSTATE_Focused ||
m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused ||
m_pEdit->GetStates() & FWL_WGTSTATE_Focused;
}
-void CFWL_DateTimePicker::DisForm_Update() {
- if (m_iLock)
- return;
- if (!m_pProperties->m_pThemeProvider)
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
-
- m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider);
- m_rtClient = GetClientRect();
- m_pEdit->SetWidgetRect(m_rtClient);
- ResetEditAlignment();
- m_pEdit->Update();
-
- if (!m_pMonthCal->GetThemeProvider())
- m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider);
-
- IFWL_ThemeProvider* theme = GetAvailableTheme();
- if (!theme)
- return;
-
- m_fBtn = theme->GetScrollBarWidth();
- CFX_RectF rtMonthCal = m_pMonthCal->GetAutosizedWidgetRect();
- CFX_RectF rtPopUp(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight,
- rtMonthCal.width, rtMonthCal.height);
- m_pMonthCal->SetWidgetRect(rtPopUp);
- m_pMonthCal->Update();
-}
-
-CFX_RectF CFWL_DateTimePicker::DisForm_GetBBox() const {
- CFX_RectF rect = m_pProperties->m_rtWidget;
- if (DisForm_IsNeedShowButton())
- rect.width += m_fBtn;
- if (!IsMonthCalendarVisible())
- return rect;
-
- CFX_RectF rtMonth = m_pMonthCal->GetWidgetRect();
- rtMonth.Offset(m_pProperties->m_rtWidget.left, m_pProperties->m_rtWidget.top);
- rect.Union(rtMonth);
- return rect;
-}
-
-void CFWL_DateTimePicker::DisForm_DrawWidget(CXFA_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- if (!pGraphics)
- return;
- if (m_pEdit) {
- CFX_RectF rtEdit = m_pEdit->GetWidgetRect();
-
- CFX_Matrix mt(1, 0, 0, 1, rtEdit.left, rtEdit.top);
- if (pMatrix)
- mt.Concat(*pMatrix);
- m_pEdit->DrawWidget(pGraphics, mt);
- }
- if (!IsMonthCalendarVisible())
- return;
-
- CFX_RectF rtMonth = m_pMonthCal->GetWidgetRect();
- CFX_Matrix mt(1, 0, 0, 1, rtMonth.left, rtMonth.top);
- if (pMatrix)
- mt.Concat(*pMatrix);
- m_pMonthCal->DrawWidget(pGraphics, mt);
-}
-
void CFWL_DateTimePicker::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
return;
@@ -434,7 +403,30 @@ void CFWL_DateTimePicker::OnDrawWidget(CXFA_Graphics* pGraphics,
void CFWL_DateTimePicker::OnFocusChanged(CFWL_Message* pMsg, bool bSet) {
if (!pMsg)
return;
- DisForm_OnFocusChanged(pMsg, bSet);
+
+ CFX_RectF rtInvalidate(m_rtBtn);
+ if (bSet) {
+ m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ if (m_pEdit && !(m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly)) {
+ m_rtBtn = CFX_RectF(m_pProperties->m_rtWidget.width, 0, m_fBtn,
+ m_pProperties->m_rtWidget.height - 1);
+ }
+ rtInvalidate = m_rtBtn;
+ pMsg->m_pDstTarget = m_pEdit.get();
+ m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
+ } else {
+ m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+ m_rtBtn.Reset();
+
+ if (IsMonthCalendarVisible())
+ ShowMonthCalendar(false);
+ if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
+ pMsg->m_pSrcTarget = m_pEdit.get();
+ m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
+ }
+ }
+ rtInvalidate.Inflate(2, 2);
+ RepaintRect(rtInvalidate);
}
void CFWL_DateTimePicker::OnLButtonDown(CFWL_MessageMouse* pMsg) {
@@ -480,33 +472,6 @@ void CFWL_DateTimePicker::OnMouseLeave(CFWL_MessageMouse* pMsg) {
RepaintRect(m_rtBtn);
}
-void CFWL_DateTimePicker::DisForm_OnFocusChanged(CFWL_Message* pMsg,
- bool bSet) {
- CFX_RectF rtInvalidate(m_rtBtn);
- if (bSet) {
- m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- if (m_pEdit && !(m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly)) {
- m_rtBtn = CFX_RectF(m_pProperties->m_rtWidget.width, 0, m_fBtn,
- m_pProperties->m_rtWidget.height - 1);
- }
- rtInvalidate = m_rtBtn;
- pMsg->m_pDstTarget = m_pEdit.get();
- m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
- } else {
- m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- m_rtBtn.Reset();
-
- if (DisForm_IsMonthCalendarVisible())
- ShowMonthCalendar(false);
- if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
- pMsg->m_pSrcTarget = m_pEdit.get();
- m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
- }
- }
- rtInvalidate.Inflate(2, 2);
- RepaintRect(rtInvalidate);
-}
-
void CFWL_DateTimePicker::GetPopupPos(float fMinHeight,
float fMaxHeight,
const CFX_RectF& rtAnchor,
diff --git a/xfa/fwl/cfwl_datetimepicker.h b/xfa/fwl/cfwl_datetimepicker.h
index 4bfd3d022a..cf0bc2cfca 100644
--- a/xfa/fwl/cfwl_datetimepicker.h
+++ b/xfa/fwl/cfwl_datetimepicker.h
@@ -85,14 +85,7 @@ class CFWL_DateTimePicker : public CFWL_Widget {
void OnMouseMove(CFWL_MessageMouse* pMsg);
void OnMouseLeave(CFWL_MessageMouse* pMsg);
- bool DisForm_IsMonthCalendarVisible() const;
- void DisForm_ShowMonthCalendar(bool bActivate);
- FWL_WidgetHit DisForm_HitTest(const CFX_PointF& point) const;
- bool DisForm_IsNeedShowButton() const;
- void DisForm_Update();
- CFX_RectF DisForm_GetBBox() const;
- void DisForm_DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix);
- void DisForm_OnFocusChanged(CFWL_Message* pMsg, bool bSet);
+ bool NeedsToShowButton() const;
CFX_RectF m_rtBtn;
CFX_RectF m_rtClient;
diff --git a/xfa/fwl/cfwl_monthcalendar.cpp b/xfa/fwl/cfwl_monthcalendar.cpp
index 9ee6d6670c..7f4c1ebf1a 100644
--- a/xfa/fwl/cfwl_monthcalendar.cpp
+++ b/xfa/fwl/cfwl_monthcalendar.cpp
@@ -765,10 +765,6 @@ void CFWL_MonthCalendar::OnLButtonDown(CFWL_MessageMouse* pMsg) {
}
void CFWL_MonthCalendar::OnLButtonUp(CFWL_MessageMouse* pMsg) {
- return DisForm_OnLButtonUp(pMsg);
-}
-
-void CFWL_MonthCalendar::DisForm_OnLButtonUp(CFWL_MessageMouse* pMsg) {
if (m_rtLBtn.Contains(pMsg->m_pos)) {
m_iLBtnPartStates = 0;
RepaintRect(m_rtLBtn);
diff --git a/xfa/fwl/cfwl_monthcalendar.h b/xfa/fwl/cfwl_monthcalendar.h
index 7b68600bbc..3f1ea207fd 100644
--- a/xfa/fwl/cfwl_monthcalendar.h
+++ b/xfa/fwl/cfwl_monthcalendar.h
@@ -146,7 +146,6 @@ class CFWL_MonthCalendar : public CFWL_Widget {
CFX_RectF GetDayRect(int32_t iDay);
void OnLButtonDown(CFWL_MessageMouse* pMsg);
void OnLButtonUp(CFWL_MessageMouse* pMsg);
- void DisForm_OnLButtonUp(CFWL_MessageMouse* pMsg);
void OnMouseMove(CFWL_MessageMouse* pMsg);
void OnMouseLeave(CFWL_MessageMouse* pMsg);