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

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

Issue 2510793003: Continue formatting fwl/core (Closed)
Patch Set: format 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
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_tooltip.h" 7 #include "xfa/fwl/core/ifwl_tooltip.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 22 matching lines...) Expand all
33 m_pProperties->m_dwStyles |= FWL_WGTSTYLE_Popup; 33 m_pProperties->m_dwStyles |= FWL_WGTSTYLE_Popup;
34 } 34 }
35 35
36 IFWL_ToolTip::~IFWL_ToolTip() {} 36 IFWL_ToolTip::~IFWL_ToolTip() {}
37 37
38 FWL_Type IFWL_ToolTip::GetClassID() const { 38 FWL_Type IFWL_ToolTip::GetClassID() const {
39 return FWL_Type::ToolTip; 39 return FWL_Type::ToolTip;
40 } 40 }
41 41
42 void IFWL_ToolTip::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { 42 void IFWL_ToolTip::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
43 if (bAutoSize) { 43 if (!bAutoSize) {
44 rect.Set(0, 0, 0, 0);
45 if (!m_pProperties->m_pThemeProvider) {
46 m_pProperties->m_pThemeProvider = GetAvailableTheme();
47 }
48 CFX_WideString wsCaption;
49 IFWL_ToolTipDP* pData =
50 static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider);
51 if (pData) {
52 pData->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 rect.width += 25;
59 rect.height += 16;
60 }
61 IFWL_Widget::GetWidgetRect(rect, true);
62 } else {
63 rect = m_pProperties->m_rtWidget; 44 rect = m_pProperties->m_rtWidget;
45 return;
64 } 46 }
47
48 rect.Set(0, 0, 0, 0);
49 if (!m_pProperties->m_pThemeProvider)
50 m_pProperties->m_pThemeProvider = GetAvailableTheme();
51
52 CFX_WideString wsCaption;
53 IFWL_ToolTipDP* pData =
54 static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider);
55 if (pData)
56 pData->GetCaption(this, wsCaption);
57
58 int32_t iLen = wsCaption.GetLength();
59 if (iLen > 0) {
60 CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider);
61 rect.Set(0, 0, sz.x, sz.y);
62 rect.width += 25;
63 rect.height += 16;
64 }
65 IFWL_Widget::GetWidgetRect(rect, true);
65 } 66 }
66 67
67 void IFWL_ToolTip::Update() { 68 void IFWL_ToolTip::Update() {
68 if (IsLocked()) { 69 if (IsLocked())
69 return; 70 return;
70 } 71 if (!m_pProperties->m_pThemeProvider)
71 if (!m_pProperties->m_pThemeProvider) {
72 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 72 m_pProperties->m_pThemeProvider = GetAvailableTheme();
73 } 73
74 UpdateTextOutStyles(); 74 UpdateTextOutStyles();
75 GetClientRect(m_rtClient); 75 GetClientRect(m_rtClient);
76 m_rtCaption = m_rtClient; 76 m_rtCaption = m_rtClient;
77 } 77 }
78 78
79 void IFWL_ToolTip::GetClientRect(CFX_RectF& rect) { 79 void IFWL_ToolTip::GetClientRect(CFX_RectF& rect) {
80 FX_FLOAT x = 0; 80 FX_FLOAT x = 0;
81 FX_FLOAT y = 0; 81 FX_FLOAT y = 0;
82 FX_FLOAT t = 0; 82 FX_FLOAT t = 0;
83 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 83 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
(...skipping 21 matching lines...) Expand all
105 } 105 }
106 106
107 void IFWL_ToolTip::DrawBkground(CFX_Graphics* pGraphics, 107 void IFWL_ToolTip::DrawBkground(CFX_Graphics* pGraphics,
108 IFWL_ThemeProvider* pTheme, 108 IFWL_ThemeProvider* pTheme,
109 const CFX_Matrix* pMatrix) { 109 const CFX_Matrix* pMatrix) {
110 CFWL_ThemeBackground param; 110 CFWL_ThemeBackground param;
111 param.m_pWidget = this; 111 param.m_pWidget = this;
112 param.m_iPart = CFWL_Part::Background; 112 param.m_iPart = CFWL_Part::Background;
113 param.m_dwStates = m_pProperties->m_dwStates; 113 param.m_dwStates = m_pProperties->m_dwStates;
114 param.m_pGraphics = pGraphics; 114 param.m_pGraphics = pGraphics;
115 if (pMatrix) { 115 if (pMatrix)
116 param.m_matrix.Concat(*pMatrix); 116 param.m_matrix.Concat(*pMatrix);
117 }
118 param.m_rtPart = m_rtClient; 117 param.m_rtPart = m_rtClient;
119 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { 118 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)
120 param.m_pData = &m_rtCaption; 119 param.m_pData = &m_rtCaption;
121 }
122 pTheme->DrawBackground(&param); 120 pTheme->DrawBackground(&param);
123 } 121 }
124 122
125 void IFWL_ToolTip::DrawText(CFX_Graphics* pGraphics, 123 void IFWL_ToolTip::DrawText(CFX_Graphics* pGraphics,
126 IFWL_ThemeProvider* pTheme, 124 IFWL_ThemeProvider* pTheme,
127 const CFX_Matrix* pMatrix) { 125 const CFX_Matrix* pMatrix) {
128 if (!m_pProperties->m_pDataProvider) 126 if (!m_pProperties->m_pDataProvider)
129 return; 127 return;
128
130 CFX_WideString wsCaption; 129 CFX_WideString wsCaption;
131 m_pProperties->m_pDataProvider->GetCaption(this, wsCaption); 130 m_pProperties->m_pDataProvider->GetCaption(this, wsCaption);
132 if (wsCaption.IsEmpty()) { 131 if (wsCaption.IsEmpty())
133 return; 132 return;
134 } 133
135 CFWL_ThemeText param; 134 CFWL_ThemeText param;
136 param.m_pWidget = this; 135 param.m_pWidget = this;
137 param.m_iPart = CFWL_Part::Caption; 136 param.m_iPart = CFWL_Part::Caption;
138 param.m_dwStates = m_pProperties->m_dwStates; 137 param.m_dwStates = m_pProperties->m_dwStates;
139 param.m_pGraphics = pGraphics; 138 param.m_pGraphics = pGraphics;
140 if (pMatrix) { 139 if (pMatrix)
141 param.m_matrix.Concat(*pMatrix); 140 param.m_matrix.Concat(*pMatrix);
142 }
143 param.m_rtPart = m_rtCaption; 141 param.m_rtPart = m_rtCaption;
144 param.m_wsText = wsCaption; 142 param.m_wsText = wsCaption;
145 param.m_dwTTOStyles = m_dwTTOStyles; 143 param.m_dwTTOStyles = m_dwTTOStyles;
146 param.m_iTTOAlign = m_iTTOAlign; 144 param.m_iTTOAlign = m_iTTOAlign;
147 pTheme->DrawText(&param); 145 pTheme->DrawText(&param);
148 } 146 }
149 147
150 void IFWL_ToolTip::UpdateTextOutStyles() { 148 void IFWL_ToolTip::UpdateTextOutStyles() {
151 m_iTTOAlign = FDE_TTOALIGNMENT_Center; 149 m_iTTOAlign = FDE_TTOALIGNMENT_Center;
152 m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; 150 m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
153 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { 151 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading)
154 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; 152 m_dwTTOStyles |= FDE_TTOSTYLE_RTL;
155 } 153 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_Multiline)
156 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_Multiline) {
157 m_dwTTOStyles &= ~FDE_TTOSTYLE_SingleLine; 154 m_dwTTOStyles &= ~FDE_TTOSTYLE_SingleLine;
158 }
159 } 155 }
160 156
161 void IFWL_ToolTip::SetStates(uint32_t dwStates, bool bSet) { 157 void IFWL_ToolTip::SetStates(uint32_t dwStates, bool bSet) {
162 if ((dwStates & FWL_WGTSTATE_Invisible) && !bSet) { 158 if ((dwStates & FWL_WGTSTATE_Invisible) && !bSet) {
163 IFWL_ToolTipDP* pData = 159 IFWL_ToolTipDP* pData =
164 static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); 160 static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider);
165 int32_t nAutoPopDelay = pData->GetAutoPopDelay(this); 161 int32_t nAutoPopDelay = pData->GetAutoPopDelay(this);
166 m_pTimerInfoHide = m_TimerHide.StartTimer(nAutoPopDelay, false); 162 m_pTimerInfoHide = m_TimerHide.StartTimer(nAutoPopDelay, false);
167 } 163 }
168 IFWL_Widget::SetStates(dwStates, bSet); 164 IFWL_Widget::SetStates(dwStates, bSet);
169 } 165 }
170 166
171 void IFWL_ToolTip::RefreshToolTipPos() { 167 void IFWL_ToolTip::RefreshToolTipPos() {
172 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_NoAnchor) == 0) { 168 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_NoAnchor) == 0) {
173 CFX_RectF rtPopup; 169 CFX_RectF rtPopup;
174 CFX_RectF rtWidget(m_pProperties->m_rtWidget); 170 CFX_RectF rtWidget(m_pProperties->m_rtWidget);
175 CFX_RectF rtAnchor(m_rtAnchor); 171 CFX_RectF rtAnchor(m_rtAnchor);
176 rtPopup.Set(0, 0, 0, 0); 172 rtPopup.Set(0, 0, 0, 0);
177 FX_FLOAT fx = rtAnchor.Center().x + 20; 173 FX_FLOAT fx = rtAnchor.Center().x + 20;
178 FX_FLOAT fy = rtAnchor.Center().y + 20; 174 FX_FLOAT fy = rtAnchor.Center().y + 20;
179 rtPopup.Set(fx, fy, rtWidget.Width(), rtWidget.Height()); 175 rtPopup.Set(fx, fy, rtWidget.Width(), rtWidget.Height());
180 176
181 if (rtPopup.bottom() > 0.0f) { 177 if (rtPopup.bottom() > 0.0f)
182 rtPopup.Offset(0, 0.0f - rtPopup.bottom()); 178 rtPopup.Offset(0, 0.0f - rtPopup.bottom());
183 } 179 if (rtPopup.right() > 0.0f)
184 if (rtPopup.right() > 0.0f) {
185 rtPopup.Offset(0.0f - rtPopup.right(), 0); 180 rtPopup.Offset(0.0f - rtPopup.right(), 0);
186 } 181 if (rtPopup.left < 0)
187 if (rtPopup.left < 0) {
188 rtPopup.Offset(0 - rtPopup.left, 0); 182 rtPopup.Offset(0 - rtPopup.left, 0);
189 } 183 if (rtPopup.top < 0)
190 if (rtPopup.top < 0) {
191 rtPopup.Offset(0, 0 - rtPopup.top); 184 rtPopup.Offset(0, 0 - rtPopup.top);
192 } 185
193 SetWidgetRect(rtPopup); 186 SetWidgetRect(rtPopup);
194 Update(); 187 Update();
195 } 188 }
196 } 189 }
197 190
198 void IFWL_ToolTip::OnDrawWidget(CFX_Graphics* pGraphics, 191 void IFWL_ToolTip::OnDrawWidget(CFX_Graphics* pGraphics,
199 const CFX_Matrix* pMatrix) { 192 const CFX_Matrix* pMatrix) {
200 DrawWidget(pGraphics, pMatrix); 193 DrawWidget(pGraphics, pMatrix);
201 } 194 }
202 195
(...skipping 10 matching lines...) Expand all
213 pToolTip->m_pTimerInfoShow = nullptr; 206 pToolTip->m_pTimerInfoShow = nullptr;
214 return; 207 return;
215 } 208 }
216 } 209 }
217 if (pToolTip->m_pTimerInfoHide == pTimerInfo && pToolTip->m_pTimerInfoHide) { 210 if (pToolTip->m_pTimerInfoHide == pTimerInfo && pToolTip->m_pTimerInfoHide) {
218 pToolTip->SetStates(FWL_WGTSTATE_Invisible, true); 211 pToolTip->SetStates(FWL_WGTSTATE_Invisible, true);
219 pToolTip->m_pTimerInfoHide->StopTimer(); 212 pToolTip->m_pTimerInfoHide->StopTimer();
220 pToolTip->m_pTimerInfoHide = nullptr; 213 pToolTip->m_pTimerInfoHide = nullptr;
221 } 214 }
222 } 215 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698