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

Side by Side Diff: xfa/fwl/lightwidget/cfwl_pushbutton.cpp

Issue 2209153002: Use virtual function to retrieve interface pointer (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comment Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « xfa/fwl/lightwidget/cfwl_pushbutton.h ('k') | xfa/fwl/lightwidget/cfwl_widget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fwl/lightwidget/cfwl_pushbutton.h" 7 #include "xfa/fwl/lightwidget/cfwl_pushbutton.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
11 IFWL_PushButton* CFWL_PushButton::GetWidget() {
12 return static_cast<IFWL_PushButton*>(m_pIface.get());
13 }
14
15 const IFWL_PushButton* CFWL_PushButton::GetWidget() const {
16 return static_cast<IFWL_PushButton*>(m_pIface.get());
17 }
18
11 CFWL_PushButton* CFWL_PushButton::Create() { 19 CFWL_PushButton* CFWL_PushButton::Create() {
12 return new CFWL_PushButton; 20 return new CFWL_PushButton;
13 } 21 }
14 22
15 FWL_Error CFWL_PushButton::Initialize( 23 FWL_Error CFWL_PushButton::Initialize(
16 const CFWL_WidgetProperties* pProperties) { 24 const CFWL_WidgetProperties* pProperties) {
17 if (m_pIface) 25 if (m_pIface)
18 return FWL_Error::Indefinite; 26 return FWL_Error::Indefinite;
19 if (pProperties) { 27 if (pProperties) {
20 *m_pProperties = *pProperties; 28 *m_pProperties = *pProperties;
21 } 29 }
22 std::unique_ptr<IFWL_PushButton> pPushButton(IFWL_PushButton::Create( 30 std::unique_ptr<IFWL_PushButton> pPushButton(IFWL_PushButton::Create(
23 m_pProperties->MakeWidgetImpProperties(&m_buttonData), nullptr)); 31 m_pProperties->MakeWidgetImpProperties(&m_buttonData), nullptr));
24 FWL_Error ret = pPushButton->Initialize(); 32 FWL_Error ret = pPushButton->Initialize();
25 if (ret != FWL_Error::Succeeded) { 33 if (ret != FWL_Error::Succeeded) {
26 return ret; 34 return ret;
27 } 35 }
28 m_pIface = pPushButton.release(); 36 m_pIface = std::move(pPushButton);
29 CFWL_Widget::Initialize(); 37 CFWL_Widget::Initialize();
30 return FWL_Error::Succeeded; 38 return FWL_Error::Succeeded;
31 } 39 }
32 40
33 FWL_Error CFWL_PushButton::GetCaption(CFX_WideString& wsCaption) { 41 FWL_Error CFWL_PushButton::GetCaption(CFX_WideString& wsCaption) {
34 wsCaption = m_buttonData.m_wsCaption; 42 wsCaption = m_buttonData.m_wsCaption;
35 return FWL_Error::Succeeded; 43 return FWL_Error::Succeeded;
36 } 44 }
37 45
38 FWL_Error CFWL_PushButton::SetCaption(const CFX_WideStringC& wsCaption) { 46 FWL_Error CFWL_PushButton::SetCaption(const CFX_WideStringC& wsCaption) {
(...skipping 18 matching lines...) Expand all
57 IFWL_Widget* pWidget, 65 IFWL_Widget* pWidget,
58 CFX_WideString& wsCaption) { 66 CFX_WideString& wsCaption) {
59 wsCaption = m_wsCaption; 67 wsCaption = m_wsCaption;
60 return FWL_Error::Succeeded; 68 return FWL_Error::Succeeded;
61 } 69 }
62 70
63 CFX_DIBitmap* CFWL_PushButton::CFWL_PushButtonDP::GetPicture( 71 CFX_DIBitmap* CFWL_PushButton::CFWL_PushButtonDP::GetPicture(
64 IFWL_Widget* pWidget) { 72 IFWL_Widget* pWidget) {
65 return m_pBitmap; 73 return m_pBitmap;
66 } 74 }
OLDNEW
« no previous file with comments | « xfa/fwl/lightwidget/cfwl_pushbutton.h ('k') | xfa/fwl/lightwidget/cfwl_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698