summaryrefslogtreecommitdiff
path: root/xfa/fwl
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fwl')
-rw-r--r--xfa/fwl/cfwl_checkbox.cpp11
-rw-r--r--xfa/fwl/cfwl_monthcalendar.cpp89
-rw-r--r--xfa/fwl/cfwl_monthcalendar.h5
-rw-r--r--xfa/fwl/cfwl_widget.cpp14
-rw-r--r--xfa/fwl/cfwl_widgetmgr.cpp15
-rw-r--r--xfa/fwl/cfwl_widgetmgr.h7
6 files changed, 67 insertions, 74 deletions
diff --git a/xfa/fwl/cfwl_checkbox.cpp b/xfa/fwl/cfwl_checkbox.cpp
index 5d40d8f425..4a2d2dbaee 100644
--- a/xfa/fwl/cfwl_checkbox.cpp
+++ b/xfa/fwl/cfwl_checkbox.cpp
@@ -9,6 +9,7 @@
#include <algorithm>
#include <memory>
#include <utility>
+#include <vector>
#include "third_party/base/ptr_util.h"
#include "xfa/fde/tto/fde_textout.h"
@@ -187,12 +188,10 @@ void CFWL_CheckBox::NextStates() {
FWL_STATE_CKB_Unchecked) {
CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr();
if (!pWidgetMgr->IsFormDisabled()) {
- CFX_ArrayTemplate<CFWL_Widget*> radioarr;
- pWidgetMgr->GetSameGroupRadioButton(this, radioarr);
- CFWL_CheckBox* pCheckBox = nullptr;
- int32_t iCount = radioarr.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- pCheckBox = static_cast<CFWL_CheckBox*>(radioarr[i]);
+ std::vector<CFWL_Widget*> radioarr =
+ pWidgetMgr->GetSameGroupRadioButton(this);
+ for (const auto& pWidget : radioarr) {
+ CFWL_CheckBox* pCheckBox = static_cast<CFWL_CheckBox*>(pWidget);
if (pCheckBox != this &&
pCheckBox->GetStates() & FWL_STATE_CKB_Checked) {
pCheckBox->SetCheckState(0);
diff --git a/xfa/fwl/cfwl_monthcalendar.cpp b/xfa/fwl/cfwl_monthcalendar.cpp
index b79dc3ec6c..d72e4a0d9a 100644
--- a/xfa/fwl/cfwl_monthcalendar.cpp
+++ b/xfa/fwl/cfwl_monthcalendar.cpp
@@ -11,6 +11,7 @@
#include <utility>
#include "third_party/base/ptr_util.h"
+#include "third_party/base/stl_util.h"
#include "xfa/fde/tto/fde_textout.h"
#include "xfa/fwl/cfwl_datetimepicker.h"
#include "xfa/fwl/cfwl_formproxy.h"
@@ -115,7 +116,7 @@ CFWL_MonthCalendar::CFWL_MonthCalendar(
CFWL_MonthCalendar::~CFWL_MonthCalendar() {
ClearDateItem();
- m_arrSelDays.RemoveAll();
+ m_arrSelDays.clear();
}
FWL_Type CFWL_MonthCalendar::GetClassID() const {
@@ -279,9 +280,9 @@ void CFWL_MonthCalendar::DrawDatesInBK(CFX_Graphics* pGraphics,
if (pMatrix)
params.m_matrix.Concat(*pMatrix);
- int32_t iCount = m_arrDates.GetSize();
+ int32_t iCount = pdfium::CollectionSize<int32_t>(m_arrDates);
for (int32_t j = 0; j < iCount; j++) {
- DATEINFO* pDataInfo = m_arrDates.GetAt(j);
+ DATEINFO* pDataInfo = m_arrDates[j].get();
if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Selected) {
params.m_dwStates |= CFWL_PartState_Selected;
if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) {
@@ -355,9 +356,9 @@ void CFWL_MonthCalendar::DrawDatesIn(CFX_Graphics* pGraphics,
if (pMatrix)
params.m_matrix.Concat(*pMatrix);
- int32_t iCount = m_arrDates.GetSize();
+ int32_t iCount = pdfium::CollectionSize<int32_t>(m_arrDates);
for (int32_t j = 0; j < iCount; j++) {
- DATEINFO* pDataInfo = m_arrDates.GetAt(j);
+ DATEINFO* pDataInfo = m_arrDates[j].get();
params.m_wsText = pDataInfo->wsDay;
params.m_rtPart = pDataInfo->rect;
params.m_dwStates = pDataInfo->dwStates;
@@ -387,10 +388,11 @@ void CFWL_MonthCalendar::DrawDatesInCircle(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
if (m_iMonth != m_iCurMonth || m_iYear != m_iCurYear)
return;
- if (m_iDay < 1 || m_iDay > m_arrDates.GetSize())
+
+ if (m_iDay < 1 || m_iDay > pdfium::CollectionSize<int32_t>(m_arrDates))
return;
- DATEINFO* pDate = m_arrDates[m_iDay - 1];
+ DATEINFO* pDate = m_arrDates[m_iDay - 1].get();
if (!pDate)
return;
@@ -521,9 +523,7 @@ void CFWL_MonthCalendar::CalDateItem() {
int32_t iWeekOfMonth = 0;
FX_FLOAT fLeft = m_rtDates.left;
FX_FLOAT fTop = m_rtDates.top;
- int32_t iCount = m_arrDates.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- DATEINFO* pDateInfo = m_arrDates.GetAt(i);
+ for (const auto& pDateInfo : m_arrDates) {
if (bNewWeek) {
iWeekOfMonth++;
bNewWeek = false;
@@ -559,9 +559,7 @@ void CFWL_MonthCalendar::InitDate() {
}
void CFWL_MonthCalendar::ClearDateItem() {
- for (int32_t i = 0; i < m_arrDates.GetSize(); i++)
- delete m_arrDates.GetAt(i);
- m_arrDates.RemoveAll();
+ m_arrDates.clear();
}
void CFWL_MonthCalendar::ResetDateItem() {
@@ -577,12 +575,13 @@ void CFWL_MonthCalendar::ResetDateItem() {
uint32_t dwStates = 0;
if (m_iYear == m_iCurYear && m_iMonth == m_iCurMonth && m_iDay == (i + 1))
dwStates |= FWL_ITEMSTATE_MCD_Flag;
- if (m_arrSelDays.Find(i + 1) != -1)
+ if (pdfium::ContainsValue(m_arrSelDays, i + 1))
dwStates |= FWL_ITEMSTATE_MCD_Selected;
CFX_RectF rtDate;
rtDate.Set(0, 0, 0, 0);
- m_arrDates.Add(new DATEINFO(i + 1, iDayOfWeek, dwStates, rtDate, wsDay));
+ m_arrDates.push_back(pdfium::MakeUnique<DATEINFO>(i + 1, iDayOfWeek,
+ dwStates, rtDate, wsDay));
iDayOfWeek++;
}
}
@@ -634,30 +633,24 @@ void CFWL_MonthCalendar::ChangeToMonth(int32_t iYear, int32_t iMonth) {
}
void CFWL_MonthCalendar::RemoveSelDay() {
- int32_t iCount = m_arrSelDays.GetSize();
- int32_t iDatesCount = m_arrDates.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- int32_t iSelDay = m_arrSelDays.GetAt(i);
- if (iSelDay <= iDatesCount) {
- DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1);
- pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected;
- }
+ int32_t iDatesCount = pdfium::CollectionSize<int32_t>(m_arrDates);
+ for (int32_t iSelDay : m_arrSelDays) {
+ if (iSelDay <= iDatesCount)
+ m_arrDates[iSelDay - 1]->dwStates &= ~FWL_ITEMSTATE_MCD_Selected;
}
- m_arrSelDays.RemoveAll();
- return;
+ m_arrSelDays.clear();
}
void CFWL_MonthCalendar::AddSelDay(int32_t iDay) {
ASSERT(iDay > 0);
- if (m_arrSelDays.Find(iDay) != -1)
+ if (!pdfium::ContainsValue(m_arrSelDays, iDay))
return;
RemoveSelDay();
- if (iDay <= m_arrDates.GetSize()) {
- DATEINFO* pDateInfo = m_arrDates.GetAt(iDay - 1);
- pDateInfo->dwStates |= FWL_ITEMSTATE_MCD_Selected;
- }
- m_arrSelDays.Add(iDay);
+ if (iDay <= pdfium::CollectionSize<int32_t>(m_arrDates))
+ m_arrDates[iDay - 1]->dwStates |= FWL_ITEMSTATE_MCD_Selected;
+
+ m_arrSelDays.push_back(iDay);
}
void CFWL_MonthCalendar::JumpToToday() {
@@ -669,7 +662,7 @@ void CFWL_MonthCalendar::JumpToToday() {
return;
}
- if (m_arrSelDays.Find(m_iDay) == -1)
+ if (!pdfium::ContainsValue(m_arrSelDays, m_iDay))
AddSelDay(m_iDay);
}
@@ -693,23 +686,21 @@ CFX_WideString CFWL_MonthCalendar::GetTodayText(int32_t iYear,
}
int32_t CFWL_MonthCalendar::GetDayAtPoint(FX_FLOAT x, FX_FLOAT y) {
- int32_t iCount = m_arrDates.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- DATEINFO* pDateInfo = m_arrDates.GetAt(i);
+ int i = 1; // one-based day values.
+ for (const auto& pDateInfo : m_arrDates) {
if (pDateInfo->rect.Contains(x, y))
- return ++i;
+ return i;
+ ++i;
}
return -1;
}
CFX_RectF CFWL_MonthCalendar::GetDayRect(int32_t iDay) {
- if (iDay <= 0 || iDay > m_arrDates.GetSize())
+ if (iDay <= 0 || iDay > pdfium::CollectionSize<int32_t>(m_arrDates))
return CFX_RectF();
- DATEINFO* pDateInfo = m_arrDates[iDay - 1];
- if (!pDateInfo)
- return CFX_RectF();
- return pDateInfo->rect;
+ DATEINFO* pDateInfo = m_arrDates[iDay - 1].get();
+ return pDateInfo ? pDateInfo->rect : CFX_RectF();
}
void CFWL_MonthCalendar::OnProcessMessage(CFWL_Message* pMessage) {
@@ -791,7 +782,7 @@ void CFWL_MonthCalendar::OnLButtonUp(CFWL_MessageMouse* pMsg) {
return;
int32_t iOldSel = 0;
- if (m_arrSelDays.GetSize() > 0)
+ if (!m_arrSelDays.empty())
iOldSel = m_arrSelDays[0];
int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
@@ -799,10 +790,10 @@ void CFWL_MonthCalendar::OnLButtonUp(CFWL_MessageMouse* pMsg) {
CFX_RectF rt = pIPicker->GetFormProxy()->GetWidgetRect();
rt.Set(0, 0, rt.width, rt.height);
if (iCurSel > 0) {
- DATEINFO* lpDatesInfo = m_arrDates.GetAt(iCurSel - 1);
+ DATEINFO* lpDatesInfo = m_arrDates[iCurSel - 1].get();
CFX_RectF rtInvalidate(lpDatesInfo->rect);
- if (iOldSel > 0 && iOldSel <= m_arrDates.GetSize()) {
- lpDatesInfo = m_arrDates.GetAt(iOldSel - 1);
+ if (iOldSel > 0 && iOldSel <= pdfium::CollectionSize<int32_t>(m_arrDates)) {
+ lpDatesInfo = m_arrDates[iOldSel - 1].get();
rtInvalidate.Union(lpDatesInfo->rect);
}
AddSelDay(iCurSel);
@@ -832,15 +823,15 @@ void CFWL_MonthCalendar::DisForm_OnLButtonUp(CFWL_MessageMouse* pMsg) {
return;
int32_t iOldSel = 0;
- if (m_arrSelDays.GetSize() > 0)
+ if (!m_arrSelDays.empty())
iOldSel = m_arrSelDays[0];
int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
if (iCurSel > 0) {
- DATEINFO* lpDatesInfo = m_arrDates.GetAt(iCurSel - 1);
+ DATEINFO* lpDatesInfo = m_arrDates[iCurSel - 1].get();
CFX_RectF rtInvalidate(lpDatesInfo->rect);
- if (iOldSel > 0 && iOldSel <= m_arrDates.GetSize()) {
- lpDatesInfo = m_arrDates.GetAt(iOldSel - 1);
+ if (iOldSel > 0 && iOldSel <= pdfium::CollectionSize<int32_t>(m_arrDates)) {
+ lpDatesInfo = m_arrDates[iOldSel - 1].get();
rtInvalidate.Union(lpDatesInfo->rect);
}
AddSelDay(iCurSel);
diff --git a/xfa/fwl/cfwl_monthcalendar.h b/xfa/fwl/cfwl_monthcalendar.h
index 6c1d0d9246..245663cf5e 100644
--- a/xfa/fwl/cfwl_monthcalendar.h
+++ b/xfa/fwl/cfwl_monthcalendar.h
@@ -8,6 +8,7 @@
#define XFA_FWL_CFWL_MONTHCALENDAR_H_
#include <memory>
+#include <vector>
#include "xfa/fgas/localization/fgas_datetime.h"
#include "xfa/fwl/cfwl_event.h"
@@ -165,7 +166,7 @@ class CFWL_MonthCalendar : public CFWL_Widget {
CFX_WideString m_wsHead;
CFX_WideString m_wsToday;
std::unique_ptr<CFX_DateTime> m_pDateTime;
- CFX_ArrayTemplate<DATEINFO*> m_arrDates;
+ std::vector<std::unique_ptr<DATEINFO>> m_arrDates;
int32_t m_iCurYear;
int32_t m_iCurMonth;
int32_t m_iYear;
@@ -179,7 +180,7 @@ class CFWL_MonthCalendar : public CFWL_Widget {
CFX_SizeF m_szHead;
CFX_SizeF m_szCell;
CFX_SizeF m_szToday;
- CFX_ArrayTemplate<int32_t> m_arrSelDays;
+ std::vector<int32_t> m_arrSelDays;
CFX_RectF m_rtClient;
bool m_bFlag;
};
diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp
index 301ad5fc9d..e7085ba405 100644
--- a/xfa/fwl/cfwl_widget.cpp
+++ b/xfa/fwl/cfwl_widget.cpp
@@ -8,7 +8,9 @@
#include <algorithm>
#include <utility>
+#include <vector>
+#include "third_party/base/stl_util.h"
#include "xfa/fde/tto/fde_textout.h"
#include "xfa/fwl/cfwl_app.h"
#include "xfa/fwl/cfwl_combobox.h"
@@ -220,19 +222,18 @@ CFX_Matrix CFWL_Widget::GetMatrix() {
return CFX_Matrix();
CFWL_Widget* parent = GetParent();
- CFX_ArrayTemplate<CFWL_Widget*> parents;
+ std::vector<CFWL_Widget*> parents;
while (parent) {
- parents.Add(parent);
+ parents.push_back(parent);
parent = parent->GetParent();
}
CFX_Matrix matrix;
CFX_Matrix ctmOnParent;
CFX_RectF rect;
- int32_t count = parents.GetSize();
+ int32_t count = pdfium::CollectionSize<int32_t>(parents);
for (int32_t i = count - 2; i >= 0; i--) {
- parent = parents.GetAt(i);
-
+ parent = parents[i];
if (parent->m_pProperties)
ctmOnParent.SetIdentity();
rect = parent->GetWidgetRect();
@@ -242,8 +243,7 @@ CFX_Matrix CFWL_Widget::GetMatrix() {
CFX_Matrix m;
m.SetIdentity();
matrix.Concat(m, true);
- parents.RemoveAll();
-
+ parents.clear();
return matrix;
}
diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp
index dc3b383466..ea78c1a444 100644
--- a/xfa/fwl/cfwl_widgetmgr.cpp
+++ b/xfa/fwl/cfwl_widgetmgr.cpp
@@ -320,17 +320,18 @@ CFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader(
return nullptr;
}
-void CFWL_WidgetMgr::GetSameGroupRadioButton(
- CFWL_Widget* pRadioButton,
- CFX_ArrayTemplate<CFWL_Widget*>& group) const {
+std::vector<CFWL_Widget*> CFWL_WidgetMgr::GetSameGroupRadioButton(
+ CFWL_Widget* pRadioButton) const {
CFWL_Widget* pFirst = GetFirstSiblingWidget(pRadioButton);
if (!pFirst)
pFirst = pRadioButton;
- int32_t iGroup = CountRadioButtonGroup(pFirst);
- if (iGroup < 2)
- return;
- group.Add(GetRadioButtonGroupHeader(pRadioButton));
+ if (CountRadioButtonGroup(pFirst) < 2)
+ return std::vector<CFWL_Widget*>();
+
+ std::vector<CFWL_Widget*> group;
+ group.push_back(GetRadioButtonGroupHeader(pRadioButton));
+ return group;
}
CFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(CFWL_Widget* pParent) const {
diff --git a/xfa/fwl/cfwl_widgetmgr.h b/xfa/fwl/cfwl_widgetmgr.h
index 62ea60a182..baa2d1a628 100644
--- a/xfa/fwl/cfwl_widgetmgr.h
+++ b/xfa/fwl/cfwl_widgetmgr.h
@@ -9,6 +9,7 @@
#include <map>
#include <memory>
+#include <vector>
#include "core/fxcrt/fx_system.h"
#include "xfa/fwl/fwl_error.h"
@@ -50,11 +51,11 @@ class CFWL_WidgetMgr : public CFWL_WidgetMgrDelegate {
void SetParent(CFWL_Widget* pParent, CFWL_Widget* pChild);
CFWL_Widget* GetWidgetAtPoint(CFWL_Widget* pParent, FX_FLOAT fx, FX_FLOAT fy);
-
CFWL_Widget* NextTab(CFWL_Widget* parent, CFWL_Widget* focus, bool& bFind);
- void GetSameGroupRadioButton(CFWL_Widget* pRadioButton,
- CFX_ArrayTemplate<CFWL_Widget*>& group) const;
+ std::vector<CFWL_Widget*> GetSameGroupRadioButton(
+ CFWL_Widget* pRadioButton) const;
+
CFWL_Widget* GetDefaultButton(CFWL_Widget* pParent) const;
void AddRedrawCounts(CFWL_Widget* pWidget);