OLD | NEW |
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_form.h" | 7 #include "xfa/fwl/core/ifwl_form.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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 FWL_Type IFWL_Form::GetClassID() const { | 79 FWL_Type IFWL_Form::GetClassID() const { |
80 return FWL_Type::Form; | 80 return FWL_Type::Form; |
81 } | 81 } |
82 | 82 |
83 bool IFWL_Form::IsInstance(const CFX_WideStringC& wsClass) const { | 83 bool IFWL_Form::IsInstance(const CFX_WideStringC& wsClass) const { |
84 if (wsClass == CFX_WideStringC(FWL_CLASS_Form)) | 84 if (wsClass == CFX_WideStringC(FWL_CLASS_Form)) |
85 return true; | 85 return true; |
86 return IFWL_Widget::IsInstance(wsClass); | 86 return IFWL_Widget::IsInstance(wsClass); |
87 } | 87 } |
88 | 88 |
89 FWL_Error IFWL_Form::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { | 89 void IFWL_Form::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { |
90 if (bAutoSize) { | 90 if (bAutoSize) { |
91 rect.Reset(); | 91 rect.Reset(); |
92 FX_FLOAT fCapHeight = GetCaptionHeight(); | 92 FX_FLOAT fCapHeight = GetCaptionHeight(); |
93 FX_FLOAT fCXBorder = GetBorderSize(true); | 93 FX_FLOAT fCXBorder = GetBorderSize(true); |
94 FX_FLOAT fCYBorder = GetBorderSize(false); | 94 FX_FLOAT fCYBorder = GetBorderSize(false); |
95 FX_FLOAT fEdge = GetEdgeWidth(); | 95 FX_FLOAT fEdge = GetEdgeWidth(); |
96 rect.height += fCapHeight + fCYBorder + fEdge + fEdge; | 96 rect.height += fCapHeight + fCYBorder + fEdge + fEdge; |
97 rect.width += fCXBorder + fCXBorder + fEdge + fEdge; | 97 rect.width += fCXBorder + fCXBorder + fEdge + fEdge; |
98 } else { | 98 } else { |
99 rect = m_pProperties->m_rtWidget; | 99 rect = m_pProperties->m_rtWidget; |
100 } | 100 } |
101 return FWL_Error::Succeeded; | |
102 } | 101 } |
103 FWL_Error IFWL_Form::GetClientRect(CFX_RectF& rect) { | 102 void IFWL_Form::GetClientRect(CFX_RectF& rect) { |
104 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) == 0) { | 103 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) == 0) { |
105 rect = m_pProperties->m_rtWidget; | 104 rect = m_pProperties->m_rtWidget; |
106 rect.Offset(-rect.left, -rect.top); | 105 rect.Offset(-rect.left, -rect.top); |
107 return FWL_Error::Succeeded; | 106 return; |
108 } | 107 } |
109 #ifdef FWL_UseMacSystemBorder | 108 #ifdef FWL_UseMacSystemBorder |
110 rect = m_rtRelative; | 109 rect = m_rtRelative; |
111 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); | 110 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); |
112 if (!pWidgetMgr) | 111 if (!pWidgetMgr) |
113 return FWL_Error::Indefinite; | 112 return; |
114 | 113 |
115 rect.left = 0; | 114 rect.left = 0; |
116 rect.top = 0; | 115 rect.top = 0; |
117 return FWL_Error::Succeeded; | |
118 #else | 116 #else |
119 FX_FLOAT x = 0; | 117 FX_FLOAT x = 0; |
120 FX_FLOAT y = 0; | 118 FX_FLOAT y = 0; |
121 FX_FLOAT t = 0; | 119 FX_FLOAT t = 0; |
122 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 120 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
123 if (pTheme) { | 121 if (pTheme) { |
124 CFWL_ThemePart part; | 122 CFWL_ThemePart part; |
125 part.m_pWidget = this; | 123 part.m_pWidget = this; |
126 x = *static_cast<FX_FLOAT*>( | 124 x = *static_cast<FX_FLOAT*>( |
127 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CXBorder)); | 125 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CXBorder)); |
128 y = *static_cast<FX_FLOAT*>( | 126 y = *static_cast<FX_FLOAT*>( |
129 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CYBorder)); | 127 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CYBorder)); |
130 t = *static_cast<FX_FLOAT*>( | 128 t = *static_cast<FX_FLOAT*>( |
131 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CYCaption)); | 129 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CYCaption)); |
132 } | 130 } |
133 rect = m_pProperties->m_rtWidget; | 131 rect = m_pProperties->m_rtWidget; |
134 rect.Offset(-rect.left, -rect.top); | 132 rect.Offset(-rect.left, -rect.top); |
135 rect.Deflate(x, t, x, y); | 133 rect.Deflate(x, t, x, y); |
136 return FWL_Error::Succeeded; | |
137 #endif | 134 #endif |
138 } | 135 } |
139 FWL_Error IFWL_Form::Update() { | 136 void IFWL_Form::Update() { |
140 if (m_iLock > 0) { | 137 if (m_iLock > 0) { |
141 return FWL_Error::Succeeded; | 138 return; |
142 } | 139 } |
143 if (!m_pProperties->m_pThemeProvider) { | 140 if (!m_pProperties->m_pThemeProvider) { |
144 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 141 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
145 } | 142 } |
146 #ifdef FWL_UseMacSystemBorder | 143 #ifdef FWL_UseMacSystemBorder |
147 #else | 144 #else |
148 SetThemeData(); | 145 SetThemeData(); |
149 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) { | 146 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) { |
150 UpdateIcon(); | 147 UpdateIcon(); |
151 } | 148 } |
152 #endif | 149 #endif |
153 UpdateCaption(); | 150 UpdateCaption(); |
154 Layout(); | 151 Layout(); |
155 return FWL_Error::Succeeded; | |
156 } | 152 } |
157 FWL_WidgetHit IFWL_Form::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 153 FWL_WidgetHit IFWL_Form::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
158 GetAvailableTheme(); | 154 GetAvailableTheme(); |
159 if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) | 155 if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) |
160 return FWL_WidgetHit::CloseBox; | 156 return FWL_WidgetHit::CloseBox; |
161 if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) | 157 if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) |
162 return FWL_WidgetHit::MaxBox; | 158 return FWL_WidgetHit::MaxBox; |
163 if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) | 159 if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) |
164 return FWL_WidgetHit::MinBox; | 160 return FWL_WidgetHit::MinBox; |
165 CFX_RectF rtCap; | 161 CFX_RectF rtCap; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 if (rt.Contains(fx, fy)) | 195 if (rt.Contains(fx, fy)) |
200 return FWL_WidgetHit::RightTop; | 196 return FWL_WidgetHit::RightTop; |
201 rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge, | 197 rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge, |
202 m_rtRelative.height - m_fCXBorder - kCornerEnlarge, | 198 m_rtRelative.height - m_fCXBorder - kCornerEnlarge, |
203 m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); | 199 m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); |
204 if (rt.Contains(fx, fy)) | 200 if (rt.Contains(fx, fy)) |
205 return FWL_WidgetHit::RightBottom; | 201 return FWL_WidgetHit::RightBottom; |
206 } | 202 } |
207 return FWL_WidgetHit::Client; | 203 return FWL_WidgetHit::Client; |
208 } | 204 } |
209 FWL_Error IFWL_Form::DrawWidget(CFX_Graphics* pGraphics, | 205 void IFWL_Form::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { |
210 const CFX_Matrix* pMatrix) { | |
211 if (!pGraphics) | 206 if (!pGraphics) |
212 return FWL_Error::Indefinite; | 207 return; |
213 if (!m_pProperties->m_pThemeProvider) | 208 if (!m_pProperties->m_pThemeProvider) |
214 return FWL_Error::Indefinite; | 209 return; |
215 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 210 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
216 bool bInactive = !IsActive(); | 211 bool bInactive = !IsActive(); |
217 int32_t iState = bInactive ? CFWL_PartState_Inactive : CFWL_PartState_Normal; | 212 int32_t iState = bInactive ? CFWL_PartState_Inactive : CFWL_PartState_Normal; |
218 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_NoDrawClient) == 0) { | 213 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_NoDrawClient) == 0) { |
219 DrawBackground(pGraphics, pTheme); | 214 DrawBackground(pGraphics, pTheme); |
220 } | 215 } |
221 #ifdef FWL_UseMacSystemBorder | 216 #ifdef FWL_UseMacSystemBorder |
222 return FWL_Error::Succeeded; | 217 return; |
223 #endif | 218 #endif |
224 CFWL_ThemeBackground param; | 219 CFWL_ThemeBackground param; |
225 param.m_pWidget = this; | 220 param.m_pWidget = this; |
226 param.m_dwStates = iState; | 221 param.m_dwStates = iState; |
227 param.m_pGraphics = pGraphics; | 222 param.m_pGraphics = pGraphics; |
228 param.m_rtPart = m_rtRelative; | 223 param.m_rtPart = m_rtRelative; |
229 if (pMatrix) { | 224 if (pMatrix) { |
230 param.m_matrix.Concat(*pMatrix); | 225 param.m_matrix.Concat(*pMatrix); |
231 } | 226 } |
232 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) { | 227 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 pTheme->DrawBackground(¶m); | 310 pTheme->DrawBackground(¶m); |
316 } | 311 } |
317 if (m_pMinBox) { | 312 if (m_pMinBox) { |
318 param.m_iPart = CFWL_Part::MinimizeBox; | 313 param.m_iPart = CFWL_Part::MinimizeBox; |
319 param.m_dwStates = m_pMinBox->GetPartState(); | 314 param.m_dwStates = m_pMinBox->GetPartState(); |
320 param.m_rtPart = m_pMinBox->m_rtBtn; | 315 param.m_rtPart = m_pMinBox->m_rtBtn; |
321 pTheme->DrawBackground(¶m); | 316 pTheme->DrawBackground(¶m); |
322 } | 317 } |
323 } | 318 } |
324 #endif | 319 #endif |
325 return FWL_Error::Succeeded; | |
326 } | 320 } |
327 | 321 |
328 FWL_FORMSIZE IFWL_Form::GetFormSize() { | 322 FWL_FORMSIZE IFWL_Form::GetFormSize() { |
329 return m_eFormSize; | 323 return m_eFormSize; |
330 } | 324 } |
331 | 325 |
332 FWL_Error IFWL_Form::SetFormSize(FWL_FORMSIZE eFormSize) { | 326 FWL_Error IFWL_Form::SetFormSize(FWL_FORMSIZE eFormSize) { |
333 m_eFormSize = eFormSize; | 327 m_eFormSize = eFormSize; |
334 return FWL_Error::Succeeded; | 328 return FWL_Error::Succeeded; |
335 } | 329 } |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 | 1058 |
1065 uint32_t CFWL_SysBtn::GetPartState() const { | 1059 uint32_t CFWL_SysBtn::GetPartState() const { |
1066 if (IsDisabled()) | 1060 if (IsDisabled()) |
1067 return CFWL_PartState_Disabled; | 1061 return CFWL_PartState_Disabled; |
1068 if (m_dwState & FWL_SYSBUTTONSTATE_Pressed) | 1062 if (m_dwState & FWL_SYSBUTTONSTATE_Pressed) |
1069 return CFWL_PartState_Pressed; | 1063 return CFWL_PartState_Pressed; |
1070 if (m_dwState & FWL_SYSBUTTONSTATE_Hover) | 1064 if (m_dwState & FWL_SYSBUTTONSTATE_Hover) |
1071 return CFWL_PartState_Hovered; | 1065 return CFWL_PartState_Hovered; |
1072 return CFWL_PartState_Normal; | 1066 return CFWL_PartState_Normal; |
1073 } | 1067 } |
OLD | NEW |