summaryrefslogtreecommitdiff
path: root/xfa/fxfa/app/xfa_ffcheckbutton.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-04-14 17:07:09 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-18 14:11:29 +0000
commit5f28b86694455e5ef37736b73fe17d2c271ac721 (patch)
tree46c93dd9028d12f813f56ad8d1b12fee818de7a4 /xfa/fxfa/app/xfa_ffcheckbutton.cpp
parent0f9b0a9d72a46cf708866aebc5f1103087b3d2c2 (diff)
downloadpdfium-5f28b86694455e5ef37736b73fe17d2c271ac721.tar.xz
Use unique_ptr for m_pNormalWidget
Change-Id: I8f28171b55c625061bb047899dbfcd4a61004e09 Reviewed-on: https://pdfium-review.googlesource.com/4253 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/app/xfa_ffcheckbutton.cpp')
-rw-r--r--xfa/fxfa/app/xfa_ffcheckbutton.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp
index 9f003ad3a1..bc4eda0e35 100644
--- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp
+++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp
@@ -6,6 +6,8 @@
#include "xfa/fxfa/app/xfa_ffcheckbutton.h"
+#include <utility>
+#include "third_party/base/ptr_util.h"
#include "xfa/fwl/cfwl_checkbox.h"
#include "xfa/fwl/cfwl_messagemouse.h"
#include "xfa/fwl/cfwl_notedriver.h"
@@ -24,17 +26,17 @@ CXFA_FFCheckButton::CXFA_FFCheckButton(CXFA_WidgetAcc* pDataAcc)
CXFA_FFCheckButton::~CXFA_FFCheckButton() {}
bool CXFA_FFCheckButton::LoadWidget() {
- CFWL_CheckBox* pCheckBox = new CFWL_CheckBox(GetFWLApp());
- m_pNormalWidget = pCheckBox;
+ auto pNew = pdfium::MakeUnique<CFWL_CheckBox>(GetFWLApp());
+ CFWL_CheckBox* pCheckBox = pNew.get();
+ m_pNormalWidget = std::move(pNew);
m_pNormalWidget->SetLayoutItem(this);
CFWL_NoteDriver* pNoteDriver =
m_pNormalWidget->GetOwnerApp()->GetNoteDriver();
- pNoteDriver->RegisterEventTarget(m_pNormalWidget, m_pNormalWidget);
-
+ pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(),
+ m_pNormalWidget.get());
m_pOldDelegate = m_pNormalWidget->GetDelegate();
m_pNormalWidget->SetDelegate(this);
-
if (m_pDataAcc->IsRadioButton())
pCheckBox->ModifyStylesEx(FWL_STYLEEXT_CKB_RadioButton, 0xFFFFFFFF);
@@ -44,13 +46,13 @@ bool CXFA_FFCheckButton::LoadWidget() {
m_pNormalWidget->UnlockUpdate();
return CXFA_FFField::LoadWidget();
}
+
void CXFA_FFCheckButton::UpdateWidgetProperty() {
- CFWL_CheckBox* pCheckBox = (CFWL_CheckBox*)m_pNormalWidget;
- if (!m_pNormalWidget) {
+ auto* pCheckBox = static_cast<CFWL_CheckBox*>(m_pNormalWidget.get());
+ if (!pCheckBox)
return;
- }
- float fSize = m_pDataAcc->GetCheckButtonSize();
- pCheckBox->SetBoxSize(fSize);
+
+ pCheckBox->SetBoxSize(m_pDataAcc->GetCheckButtonSize());
uint32_t dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCross;
int32_t iCheckMark = m_pDataAcc->GetCheckButtonMark();
switch (iCheckMark) {
@@ -229,15 +231,17 @@ void CXFA_FFCheckButton::RenderWidget(CFX_Graphics* pGS,
m_pDataAcc->GetCheckButtonShape() == XFA_ATTRIBUTEENUM_Round);
CFX_Matrix mt(1, 0, 0, 1, m_rtCheckBox.left, m_rtCheckBox.top);
mt.Concat(mtRotate);
- GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget, pGS, &mt);
+ GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget.get(), pGS,
+ &mt);
}
+
bool CXFA_FFCheckButton::OnLButtonUp(uint32_t dwFlags,
const CFX_PointF& point) {
if (!m_pNormalWidget || !IsButtonDown())
return false;
SetButtonDown(false);
- CFWL_MessageMouse ms(nullptr, m_pNormalWidget);
+ CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get());
ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp;
ms.m_dwFlags = dwFlags;
ms.m_pos = FWLToClient(point);