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

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

Issue 2522663002: Remove the GetCaption dataprovider method (Closed)
Patch Set: Remove tooltip Created 4 years 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_tooltip.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 <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 29 matching lines...) Expand all
40 void IFWL_PushButton::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { 40 void IFWL_PushButton::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
41 if (!bAutoSize) { 41 if (!bAutoSize) {
42 rect = m_pProperties->m_rtWidget; 42 rect = m_pProperties->m_rtWidget;
43 return; 43 return;
44 } 44 }
45 45
46 rect.Set(0, 0, 0, 0); 46 rect.Set(0, 0, 0, 0);
47 if (!m_pProperties->m_pThemeProvider) 47 if (!m_pProperties->m_pThemeProvider)
48 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 48 m_pProperties->m_pThemeProvider = GetAvailableTheme();
49 49
50 CFX_WideString wsCaption;
51 if (m_pProperties->m_pDataProvider)
52 m_pProperties->m_pDataProvider->GetCaption(this, wsCaption);
53
54 int32_t iLen = wsCaption.GetLength();
55 if (iLen > 0) {
56 CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider);
57 rect.Set(0, 0, sz.x, sz.y);
58 }
59
60 FX_FLOAT* fcaption = 50 FX_FLOAT* fcaption =
61 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin)); 51 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin));
62 rect.Inflate(*fcaption, *fcaption); 52 rect.Inflate(*fcaption, *fcaption);
63 IFWL_Widget::GetWidgetRect(rect, true); 53 IFWL_Widget::GetWidgetRect(rect, true);
64 } 54 }
65 55
66 void IFWL_PushButton::SetStates(uint32_t dwStates, bool bSet) { 56 void IFWL_PushButton::SetStates(uint32_t dwStates, bool bSet) {
67 if ((dwStates & FWL_WGTSTATE_Disabled) && bSet) { 57 if ((dwStates & FWL_WGTSTATE_Disabled) && bSet) {
68 m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled; 58 m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled;
69 return; 59 return;
(...skipping 15 matching lines...) Expand all
85 m_rtCaption.Inflate(-*fcaption, -*fcaption); 75 m_rtCaption.Inflate(-*fcaption, -*fcaption);
86 } 76 }
87 77
88 void IFWL_PushButton::DrawWidget(CFX_Graphics* pGraphics, 78 void IFWL_PushButton::DrawWidget(CFX_Graphics* pGraphics,
89 const CFX_Matrix* pMatrix) { 79 const CFX_Matrix* pMatrix) {
90 if (!pGraphics) 80 if (!pGraphics)
91 return; 81 return;
92 if (!m_pProperties->m_pThemeProvider) 82 if (!m_pProperties->m_pThemeProvider)
93 return; 83 return;
94 84
95 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
96 if (HasBorder()) { 85 if (HasBorder()) {
97 DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider, 86 DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider,
98 pMatrix); 87 pMatrix);
99 } 88 }
100 if (HasEdge()) { 89 if (HasEdge()) {
101 DrawEdge(pGraphics, CFWL_Part::Edge, m_pProperties->m_pThemeProvider, 90 DrawEdge(pGraphics, CFWL_Part::Edge, m_pProperties->m_pThemeProvider,
102 pMatrix); 91 pMatrix);
103 } 92 }
104 DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); 93 DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix);
105 CFX_Matrix matrix;
106 matrix.Concat(*pMatrix);
107
108 CFX_WideString wsCaption;
109 if (m_pProperties->m_pDataProvider)
110 m_pProperties->m_pDataProvider->GetCaption(this, wsCaption);
111
112 CFX_RectF rtText;
113 rtText.Set(0, 0, 0, 0);
114 if (!wsCaption.IsEmpty())
115 CalcTextRect(wsCaption, pTheme, 0, m_iTTOAlign, rtText);
116
117 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_PSB_ModeMask) {
118 case FWL_STYLEEXT_PSB_TextOnly:
119 DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix);
120 break;
121 case FWL_STYLEEXT_PSB_IconOnly:
122 case FWL_STYLEEXT_PSB_TextIcon:
123 break;
124 }
125 } 94 }
126 95
127 void IFWL_PushButton::DrawBkground(CFX_Graphics* pGraphics, 96 void IFWL_PushButton::DrawBkground(CFX_Graphics* pGraphics,
128 IFWL_ThemeProvider* pTheme, 97 IFWL_ThemeProvider* pTheme,
129 const CFX_Matrix* pMatrix) { 98 const CFX_Matrix* pMatrix) {
130 CFWL_ThemeBackground param; 99 CFWL_ThemeBackground param;
131 param.m_pWidget = this; 100 param.m_pWidget = this;
132 param.m_iPart = CFWL_Part::Background; 101 param.m_iPart = CFWL_Part::Background;
133 param.m_dwStates = GetPartStates(); 102 param.m_dwStates = GetPartStates();
134 param.m_pGraphics = pGraphics; 103 param.m_pGraphics = pGraphics;
135 if (pMatrix) 104 if (pMatrix)
136 param.m_matrix.Concat(*pMatrix); 105 param.m_matrix.Concat(*pMatrix);
137 param.m_rtPart = m_rtClient; 106 param.m_rtPart = m_rtClient;
138 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) 107 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)
139 param.m_pData = &m_rtCaption; 108 param.m_pData = &m_rtCaption;
140 pTheme->DrawBackground(&param); 109 pTheme->DrawBackground(&param);
141 } 110 }
142 111
143 void IFWL_PushButton::DrawText(CFX_Graphics* pGraphics,
144 IFWL_ThemeProvider* pTheme,
145 const CFX_Matrix* pMatrix) {
146 if (!m_pProperties->m_pDataProvider)
147 return;
148
149 CFX_WideString wsCaption;
150 m_pProperties->m_pDataProvider->GetCaption(this, wsCaption);
151 if (wsCaption.IsEmpty())
152 return;
153
154 CFWL_ThemeText param;
155 param.m_pWidget = this;
156 param.m_iPart = CFWL_Part::Caption;
157 param.m_dwStates = GetPartStates();
158 param.m_pGraphics = pGraphics;
159 if (pMatrix)
160 param.m_matrix.Concat(*pMatrix);
161 param.m_rtPart = m_rtCaption;
162 param.m_wsText = wsCaption;
163 param.m_dwTTOStyles = m_dwTTOStyles;
164 param.m_iTTOAlign = m_iTTOAlign;
165 pTheme->DrawText(&param);
166 }
167
168 uint32_t IFWL_PushButton::GetPartStates() { 112 uint32_t IFWL_PushButton::GetPartStates() {
169 uint32_t dwStates = CFWL_PartState_Normal; 113 uint32_t dwStates = CFWL_PartState_Normal;
170 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) 114 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)
171 dwStates |= CFWL_PartState_Focused; 115 dwStates |= CFWL_PartState_Focused;
172 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) 116 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
173 dwStates = CFWL_PartState_Disabled; 117 dwStates = CFWL_PartState_Disabled;
174 else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) 118 else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed)
175 dwStates |= CFWL_PartState_Pressed; 119 dwStates |= CFWL_PartState_Pressed;
176 else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) 120 else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered)
177 dwStates |= CFWL_PartState_Hovered; 121 dwStates |= CFWL_PartState_Hovered;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 CFWL_EvtClick wmClick; 307 CFWL_EvtClick wmClick;
364 wmClick.m_pSrcTarget = this; 308 wmClick.m_pSrcTarget = this;
365 DispatchEvent(&wmClick); 309 DispatchEvent(&wmClick);
366 return; 310 return;
367 } 311 }
368 if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) 312 if (pMsg->m_dwKeyCode != FWL_VKEY_Tab)
369 return; 313 return;
370 314
371 DispatchKeyEvent(pMsg); 315 DispatchKeyEvent(pMsg);
372 } 316 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_pushbutton.h ('k') | xfa/fwl/core/ifwl_tooltip.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698