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

Side by Side Diff: xfa/fwl/core/ifwl_pushbutton.cpp

Issue 2488953003: Cleanup IFWL_Widget visibility and virtual parameters (Closed)
Patch Set: fixes Created 4 years, 1 month 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/core/ifwl_pushbutton.h ('k') | xfa/fwl/core/ifwl_scrollbar.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/core/ifwl_pushbutton.h" 7 #include "xfa/fwl/core/ifwl_pushbutton.h"
8 8
9 #include "third_party/base/ptr_util.h" 9 #include "third_party/base/ptr_util.h"
10 #include "xfa/fde/tto/fde_textout.h" 10 #include "xfa/fde/tto/fde_textout.h"
(...skipping 14 matching lines...) Expand all
25 m_rtClient.Set(0, 0, 0, 0); 25 m_rtClient.Set(0, 0, 0, 0);
26 m_rtCaption.Set(0, 0, 0, 0); 26 m_rtCaption.Set(0, 0, 0, 0);
27 } 27 }
28 28
29 IFWL_PushButton::~IFWL_PushButton() {} 29 IFWL_PushButton::~IFWL_PushButton() {}
30 30
31 FWL_Type IFWL_PushButton::GetClassID() const { 31 FWL_Type IFWL_PushButton::GetClassID() const {
32 return FWL_Type::PushButton; 32 return FWL_Type::PushButton;
33 } 33 }
34 34
35 FWL_Error IFWL_PushButton::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { 35 void IFWL_PushButton::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
36 if (bAutoSize) { 36 if (bAutoSize) {
37 rect.Set(0, 0, 0, 0); 37 rect.Set(0, 0, 0, 0);
38 if (!m_pProperties->m_pThemeProvider) { 38 if (!m_pProperties->m_pThemeProvider) {
39 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 39 m_pProperties->m_pThemeProvider = GetAvailableTheme();
40 } 40 }
41 CFX_WideString wsCaption; 41 CFX_WideString wsCaption;
42 IFWL_PushButtonDP* pData = 42 IFWL_PushButtonDP* pData =
43 static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider); 43 static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider);
44 if (pData) { 44 if (pData) {
45 pData->GetCaption(this, wsCaption); 45 pData->GetCaption(this, wsCaption);
46 } 46 }
47 int32_t iLen = wsCaption.GetLength(); 47 int32_t iLen = wsCaption.GetLength();
48 if (iLen > 0) { 48 if (iLen > 0) {
49 CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider); 49 CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider);
50 rect.Set(0, 0, sz.x, sz.y); 50 rect.Set(0, 0, sz.x, sz.y);
51 } 51 }
52 FX_FLOAT* fcaption = 52 FX_FLOAT* fcaption =
53 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin)); 53 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin));
54 rect.Inflate(*fcaption, *fcaption); 54 rect.Inflate(*fcaption, *fcaption);
55 IFWL_Widget::GetWidgetRect(rect, true); 55 IFWL_Widget::GetWidgetRect(rect, true);
56 } else { 56 } else {
57 rect = m_pProperties->m_rtWidget; 57 rect = m_pProperties->m_rtWidget;
58 } 58 }
59 return FWL_Error::Succeeded;
60 } 59 }
61 60
62 void IFWL_PushButton::SetStates(uint32_t dwStates, bool bSet) { 61 void IFWL_PushButton::SetStates(uint32_t dwStates, bool bSet) {
63 if ((dwStates & FWL_WGTSTATE_Disabled) && bSet) { 62 if ((dwStates & FWL_WGTSTATE_Disabled) && bSet) {
64 m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled; 63 m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled;
65 return; 64 return;
66 } 65 }
67 IFWL_Widget::SetStates(dwStates, bSet); 66 IFWL_Widget::SetStates(dwStates, bSet);
68 } 67 }
69 68
70 FWL_Error IFWL_PushButton::Update() { 69 void IFWL_PushButton::Update() {
71 if (IsLocked()) { 70 if (IsLocked()) {
72 return FWL_Error::Indefinite; 71 return;
73 } 72 }
74 if (!m_pProperties->m_pThemeProvider) { 73 if (!m_pProperties->m_pThemeProvider) {
75 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 74 m_pProperties->m_pThemeProvider = GetAvailableTheme();
76 } 75 }
77 UpdateTextOutStyles(); 76 UpdateTextOutStyles();
78 GetClientRect(m_rtClient); 77 GetClientRect(m_rtClient);
79 m_rtCaption = m_rtClient; 78 m_rtCaption = m_rtClient;
80 FX_FLOAT* fcaption = 79 FX_FLOAT* fcaption =
81 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin)); 80 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin));
82 m_rtCaption.Inflate(-*fcaption, -*fcaption); 81 m_rtCaption.Inflate(-*fcaption, -*fcaption);
83 return FWL_Error::Succeeded;
84 } 82 }
85 83
86 FWL_Error IFWL_PushButton::DrawWidget(CFX_Graphics* pGraphics, 84 void IFWL_PushButton::DrawWidget(CFX_Graphics* pGraphics,
87 const CFX_Matrix* pMatrix) { 85 const CFX_Matrix* pMatrix) {
88 if (!pGraphics) 86 if (!pGraphics)
89 return FWL_Error::Indefinite; 87 return;
90 if (!m_pProperties->m_pThemeProvider) 88 if (!m_pProperties->m_pThemeProvider)
91 return FWL_Error::Indefinite; 89 return;
92 IFWL_PushButtonDP* pData = 90 IFWL_PushButtonDP* pData =
93 static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider); 91 static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider);
94 CFX_DIBitmap* pPicture = nullptr; 92 CFX_DIBitmap* pPicture = nullptr;
95 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 93 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
96 if (HasBorder()) { 94 if (HasBorder()) {
97 DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider, 95 DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider,
98 pMatrix); 96 pMatrix);
99 } 97 }
100 if (HasEdge()) { 98 if (HasEdge()) {
101 DrawEdge(pGraphics, CFWL_Part::Edge, m_pProperties->m_pThemeProvider, 99 DrawEdge(pGraphics, CFWL_Part::Edge, m_pProperties->m_pThemeProvider,
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 ipicheight -= rtText.height / 2; 260 ipicheight -= rtText.height / 2;
263 break; 261 break;
264 } 262 }
265 pGraphics->DrawImage(pPicture, point, &matrix); 263 pGraphics->DrawImage(pPicture, point, &matrix);
266 } 264 }
267 matrix.e += m_rtClient.left + iPicwidth; 265 matrix.e += m_rtClient.left + iPicwidth;
268 matrix.f += m_rtClient.top + ipicheight; 266 matrix.f += m_rtClient.top + ipicheight;
269 DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix); 267 DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix);
270 break; 268 break;
271 } 269 }
272 return FWL_Error::Succeeded;
273 } 270 }
274 271
275 void IFWL_PushButton::DrawBkground(CFX_Graphics* pGraphics, 272 void IFWL_PushButton::DrawBkground(CFX_Graphics* pGraphics,
276 IFWL_ThemeProvider* pTheme, 273 IFWL_ThemeProvider* pTheme,
277 const CFX_Matrix* pMatrix) { 274 const CFX_Matrix* pMatrix) {
278 CFWL_ThemeBackground param; 275 CFWL_ThemeBackground param;
279 param.m_pWidget = this; 276 param.m_pWidget = this;
280 param.m_iPart = CFWL_Part::Background; 277 param.m_iPart = CFWL_Part::Background;
281 param.m_dwStates = GetPartStates(); 278 param.m_dwStates = GetPartStates();
282 param.m_pGraphics = pGraphics; 279 param.m_pGraphics = pGraphics;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 CFWL_EvtClick wmClick; 514 CFWL_EvtClick wmClick;
518 wmClick.m_pSrcTarget = this; 515 wmClick.m_pSrcTarget = this;
519 DispatchEvent(&wmClick); 516 DispatchEvent(&wmClick);
520 return; 517 return;
521 } 518 }
522 if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) 519 if (pMsg->m_dwKeyCode != FWL_VKEY_Tab)
523 return; 520 return;
524 521
525 DispatchKeyEvent(pMsg); 522 DispatchKeyEvent(pMsg);
526 } 523 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_pushbutton.h ('k') | xfa/fwl/core/ifwl_scrollbar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698