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

Side by Side Diff: xfa/fwl/core/ifwl_tooltip.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_tooltip.h ('k') | xfa/fwl/core/ifwl_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/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_Child; 33 m_pProperties->m_dwStyles &= ~FWL_WGTSTYLE_Child;
34 m_pProperties->m_dwStyles |= FWL_WGTSTYLE_Popup; 34 m_pProperties->m_dwStyles |= FWL_WGTSTYLE_Popup;
35 } 35 }
36 36
37 IFWL_ToolTip::~IFWL_ToolTip() {} 37 IFWL_ToolTip::~IFWL_ToolTip() {}
38 38
39 FWL_Type IFWL_ToolTip::GetClassID() const { 39 FWL_Type IFWL_ToolTip::GetClassID() const {
40 return FWL_Type::ToolTip; 40 return FWL_Type::ToolTip;
41 } 41 }
42 42
43 FWL_Error IFWL_ToolTip::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { 43 void IFWL_ToolTip::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
44 if (bAutoSize) { 44 if (bAutoSize) {
45 rect.Set(0, 0, 0, 0); 45 rect.Set(0, 0, 0, 0);
46 if (!m_pProperties->m_pThemeProvider) { 46 if (!m_pProperties->m_pThemeProvider) {
47 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 47 m_pProperties->m_pThemeProvider = GetAvailableTheme();
48 } 48 }
49 CFX_WideString wsCaption; 49 CFX_WideString wsCaption;
50 IFWL_ToolTipDP* pData = 50 IFWL_ToolTipDP* pData =
51 static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); 51 static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider);
52 if (pData) { 52 if (pData) {
53 pData->GetCaption(this, wsCaption); 53 pData->GetCaption(this, wsCaption);
54 } 54 }
55 int32_t iLen = wsCaption.GetLength(); 55 int32_t iLen = wsCaption.GetLength();
56 if (iLen > 0) { 56 if (iLen > 0) {
57 CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider); 57 CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider);
58 rect.Set(0, 0, sz.x, sz.y); 58 rect.Set(0, 0, sz.x, sz.y);
59 rect.width += 25; 59 rect.width += 25;
60 rect.height += 16; 60 rect.height += 16;
61 } 61 }
62 IFWL_Widget::GetWidgetRect(rect, true); 62 IFWL_Widget::GetWidgetRect(rect, true);
63 } else { 63 } else {
64 rect = m_pProperties->m_rtWidget; 64 rect = m_pProperties->m_rtWidget;
65 } 65 }
66 return FWL_Error::Succeeded;
67 } 66 }
68 67
69 FWL_Error IFWL_ToolTip::Update() { 68 void IFWL_ToolTip::Update() {
70 if (IsLocked()) { 69 if (IsLocked()) {
71 return FWL_Error::Indefinite; 70 return;
72 } 71 }
73 if (!m_pProperties->m_pThemeProvider) { 72 if (!m_pProperties->m_pThemeProvider) {
74 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 73 m_pProperties->m_pThemeProvider = GetAvailableTheme();
75 } 74 }
76 UpdateTextOutStyles(); 75 UpdateTextOutStyles();
77 GetClientRect(m_rtClient); 76 GetClientRect(m_rtClient);
78 m_rtCaption = m_rtClient; 77 m_rtCaption = m_rtClient;
79 return FWL_Error::Succeeded;
80 } 78 }
81 79
82 FWL_Error IFWL_ToolTip::GetClientRect(CFX_RectF& rect) { 80 void IFWL_ToolTip::GetClientRect(CFX_RectF& rect) {
83 FX_FLOAT x = 0; 81 FX_FLOAT x = 0;
84 FX_FLOAT y = 0; 82 FX_FLOAT y = 0;
85 FX_FLOAT t = 0; 83 FX_FLOAT t = 0;
86 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 84 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
87 if (pTheme) { 85 if (pTheme) {
88 CFWL_ThemePart part; 86 CFWL_ThemePart part;
89 part.m_pWidget = this; 87 part.m_pWidget = this;
90 x = *static_cast<FX_FLOAT*>( 88 x = *static_cast<FX_FLOAT*>(
91 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CXBorder)); 89 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CXBorder));
92 y = *static_cast<FX_FLOAT*>( 90 y = *static_cast<FX_FLOAT*>(
93 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CYBorder)); 91 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CYBorder));
94 } 92 }
95 rect = m_pProperties->m_rtWidget; 93 rect = m_pProperties->m_rtWidget;
96 rect.Offset(-rect.left, -rect.top); 94 rect.Offset(-rect.left, -rect.top);
97 rect.Deflate(x, t, x, y); 95 rect.Deflate(x, t, x, y);
98 return FWL_Error::Succeeded;
99 } 96 }
100 97
101 FWL_Error IFWL_ToolTip::DrawWidget(CFX_Graphics* pGraphics, 98 void IFWL_ToolTip::DrawWidget(CFX_Graphics* pGraphics,
102 const CFX_Matrix* pMatrix) { 99 const CFX_Matrix* pMatrix) {
103 if (!pGraphics || !m_pProperties->m_pThemeProvider) 100 if (!pGraphics || !m_pProperties->m_pThemeProvider)
104 return FWL_Error::Indefinite; 101 return;
105 102
106 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 103 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
107 DrawBkground(pGraphics, pTheme, pMatrix); 104 DrawBkground(pGraphics, pTheme, pMatrix);
108 DrawText(pGraphics, pTheme, pMatrix); 105 DrawText(pGraphics, pTheme, pMatrix);
109 return FWL_Error::Succeeded;
110 } 106 }
111 107
112 void IFWL_ToolTip::DrawBkground(CFX_Graphics* pGraphics, 108 void IFWL_ToolTip::DrawBkground(CFX_Graphics* pGraphics,
113 IFWL_ThemeProvider* pTheme, 109 IFWL_ThemeProvider* pTheme,
114 const CFX_Matrix* pMatrix) { 110 const CFX_Matrix* pMatrix) {
115 CFWL_ThemeBackground param; 111 CFWL_ThemeBackground param;
116 param.m_pWidget = this; 112 param.m_pWidget = this;
117 param.m_iPart = CFWL_Part::Background; 113 param.m_iPart = CFWL_Part::Background;
118 param.m_dwStates = m_pProperties->m_dwStates; 114 param.m_dwStates = m_pProperties->m_dwStates;
119 param.m_pGraphics = pGraphics; 115 param.m_pGraphics = pGraphics;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 195
200 void IFWL_ToolTip::RefreshToolTipPos() { 196 void IFWL_ToolTip::RefreshToolTipPos() {
201 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_NoAnchor) == 0) { 197 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_NoAnchor) == 0) {
202 CFX_RectF rtPopup; 198 CFX_RectF rtPopup;
203 CFX_RectF rtWidget(m_pProperties->m_rtWidget); 199 CFX_RectF rtWidget(m_pProperties->m_rtWidget);
204 CFX_RectF rtAnchor(m_rtAnchor); 200 CFX_RectF rtAnchor(m_rtAnchor);
205 rtPopup.Set(0, 0, 0, 0); 201 rtPopup.Set(0, 0, 0, 0);
206 FX_FLOAT fx = rtAnchor.Center().x + 20; 202 FX_FLOAT fx = rtAnchor.Center().x + 20;
207 FX_FLOAT fy = rtAnchor.Center().y + 20; 203 FX_FLOAT fy = rtAnchor.Center().y + 20;
208 rtPopup.Set(fx, fy, rtWidget.Width(), rtWidget.Height()); 204 rtPopup.Set(fx, fy, rtWidget.Width(), rtWidget.Height());
209 FX_FLOAT fScreenWidth = 0; 205
210 FX_FLOAT fScreenHeight = 0; 206 if (rtPopup.bottom() > 0.0f) {
211 GetScreenSize(fScreenWidth, fScreenHeight); 207 rtPopup.Offset(0, 0.0f - rtPopup.bottom());
212 if (rtPopup.bottom() > fScreenHeight) {
213 rtPopup.Offset(0, fScreenHeight - rtPopup.bottom());
214 } 208 }
215 if (rtPopup.right() > fScreenWidth) { 209 if (rtPopup.right() > 0.0f) {
216 rtPopup.Offset(fScreenWidth - rtPopup.right(), 0); 210 rtPopup.Offset(0.0f - rtPopup.right(), 0);
217 } 211 }
218 if (rtPopup.left < 0) { 212 if (rtPopup.left < 0) {
219 rtPopup.Offset(0 - rtPopup.left, 0); 213 rtPopup.Offset(0 - rtPopup.left, 0);
220 } 214 }
221 if (rtPopup.top < 0) { 215 if (rtPopup.top < 0) {
222 rtPopup.Offset(0, 0 - rtPopup.top); 216 rtPopup.Offset(0, 0 - rtPopup.top);
223 } 217 }
224 SetWidgetRect(rtPopup); 218 SetWidgetRect(rtPopup);
225 Update(); 219 Update();
226 } 220 }
(...skipping 17 matching lines...) Expand all
244 pToolTip->m_pTimerInfoShow = nullptr; 238 pToolTip->m_pTimerInfoShow = nullptr;
245 return; 239 return;
246 } 240 }
247 } 241 }
248 if (pToolTip->m_pTimerInfoHide == pTimerInfo && pToolTip->m_pTimerInfoHide) { 242 if (pToolTip->m_pTimerInfoHide == pTimerInfo && pToolTip->m_pTimerInfoHide) {
249 pToolTip->SetStates(FWL_WGTSTATE_Invisible, true); 243 pToolTip->SetStates(FWL_WGTSTATE_Invisible, true);
250 pToolTip->m_pTimerInfoHide->StopTimer(); 244 pToolTip->m_pTimerInfoHide->StopTimer();
251 pToolTip->m_pTimerInfoHide = nullptr; 245 pToolTip->m_pTimerInfoHide = nullptr;
252 } 246 }
253 } 247 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_tooltip.h ('k') | xfa/fwl/core/ifwl_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698