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/fwl_formimp.h" | 7 #include "xfa/fwl/core/fwl_formimp.h" |
8 | 8 |
9 #include "xfa/fde/tto/fde_textout.h" | 9 #include "xfa/fde/tto/fde_textout.h" |
10 #include "xfa/fwl/basewidget/fwl_formproxyimp.h" | 10 #include "xfa/fwl/basewidget/fwl_formproxyimp.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 #else | 190 #else |
191 SetThemeData(); | 191 SetThemeData(); |
192 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) { | 192 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) { |
193 UpdateIcon(); | 193 UpdateIcon(); |
194 } | 194 } |
195 #endif | 195 #endif |
196 UpdateCaption(); | 196 UpdateCaption(); |
197 Layout(); | 197 Layout(); |
198 return FWL_ERR_Succeeded; | 198 return FWL_ERR_Succeeded; |
199 } | 199 } |
200 uint32_t CFWL_FormImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 200 FWL_WidgetHit CFWL_FormImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
201 (void)GetAvailableTheme(); | 201 GetAvailableTheme(); |
202 if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) { | 202 if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) |
203 return FWL_WGTHITTEST_CloseBox; | 203 return FWL_WidgetHit::CloseBox; |
204 } | 204 if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) |
205 if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) { | 205 return FWL_WidgetHit::MaxBox; |
206 return FWL_WGTHITTEST_MaxBox; | 206 if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) |
207 } | 207 return FWL_WidgetHit::MinBox; |
208 if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) { | |
209 return FWL_WGTHITTEST_MinBox; | |
210 } | |
211 CFX_RectF rtCap; | 208 CFX_RectF rtCap; |
212 rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder, | 209 rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder, |
213 m_rtCaption.width - FWL_SYSBTNSIZE * m_iSysBox - 2 * m_fCYBorder, | 210 m_rtCaption.width - FWL_SYSBTNSIZE * m_iSysBox - 2 * m_fCYBorder, |
214 m_rtCaption.height - m_fCXBorder); | 211 m_rtCaption.height - m_fCXBorder); |
215 if (rtCap.Contains(fx, fy)) { | 212 if (rtCap.Contains(fx, fy)) |
216 return FWL_WGTHITTEST_Titlebar; | 213 return FWL_WidgetHit::Titlebar; |
217 } | |
218 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && | 214 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && |
219 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize)) { | 215 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize)) { |
220 FX_FLOAT fWidth = m_rtRelative.width - 2 * (m_fCYBorder + kCornerEnlarge); | 216 FX_FLOAT fWidth = m_rtRelative.width - 2 * (m_fCYBorder + kCornerEnlarge); |
221 FX_FLOAT fHeight = m_rtRelative.height - 2 * (m_fCXBorder + kCornerEnlarge); | 217 FX_FLOAT fHeight = m_rtRelative.height - 2 * (m_fCXBorder + kCornerEnlarge); |
222 CFX_RectF rt; | 218 CFX_RectF rt; |
223 rt.Set(0, m_fCXBorder + kCornerEnlarge, m_fCYBorder, fHeight); | 219 rt.Set(0, m_fCXBorder + kCornerEnlarge, m_fCYBorder, fHeight); |
224 if (rt.Contains(fx, fy)) { | 220 if (rt.Contains(fx, fy)) |
225 return FWL_WGTHITTEST_Left; | 221 return FWL_WidgetHit::Left; |
226 } | |
227 rt.Set(m_rtRelative.width - m_fCYBorder, m_fCXBorder + kCornerEnlarge, | 222 rt.Set(m_rtRelative.width - m_fCYBorder, m_fCXBorder + kCornerEnlarge, |
228 m_fCYBorder, fHeight); | 223 m_fCYBorder, fHeight); |
229 if (rt.Contains(fx, fy)) { | 224 if (rt.Contains(fx, fy)) |
230 return FWL_WGTHITTEST_Right; | 225 return FWL_WidgetHit::Right; |
231 } | |
232 rt.Set(m_fCYBorder + kCornerEnlarge, 0, fWidth, m_fCXBorder); | 226 rt.Set(m_fCYBorder + kCornerEnlarge, 0, fWidth, m_fCXBorder); |
233 if (rt.Contains(fx, fy)) { | 227 if (rt.Contains(fx, fy)) |
234 return FWL_WGTHITTEST_Top; | 228 return FWL_WidgetHit::Top; |
235 } | |
236 rt.Set(m_fCYBorder + kCornerEnlarge, m_rtRelative.height - m_fCXBorder, | 229 rt.Set(m_fCYBorder + kCornerEnlarge, m_rtRelative.height - m_fCXBorder, |
237 fWidth, m_fCXBorder); | 230 fWidth, m_fCXBorder); |
238 if (rt.Contains(fx, fy)) { | 231 if (rt.Contains(fx, fy)) |
239 return FWL_WGTHITTEST_Bottom; | 232 return FWL_WidgetHit::Bottom; |
240 } | |
241 rt.Set(0, 0, m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); | 233 rt.Set(0, 0, m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); |
242 if (rt.Contains(fx, fy)) { | 234 if (rt.Contains(fx, fy)) |
243 return FWL_WGTHITTEST_LeftTop; | 235 return FWL_WidgetHit::LeftTop; |
244 } | |
245 rt.Set(0, m_rtRelative.height - m_fCXBorder - kCornerEnlarge, | 236 rt.Set(0, m_rtRelative.height - m_fCXBorder - kCornerEnlarge, |
246 m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); | 237 m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); |
247 if (rt.Contains(fx, fy)) { | 238 if (rt.Contains(fx, fy)) |
248 return FWL_WGTHITTEST_LeftBottom; | 239 return FWL_WidgetHit::LeftBottom; |
249 } | |
250 rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge, 0, | 240 rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge, 0, |
251 m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); | 241 m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); |
252 if (rt.Contains(fx, fy)) { | 242 if (rt.Contains(fx, fy)) |
253 return FWL_WGTHITTEST_RightTop; | 243 return FWL_WidgetHit::RightTop; |
254 } | |
255 rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge, | 244 rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge, |
256 m_rtRelative.height - m_fCXBorder - kCornerEnlarge, | 245 m_rtRelative.height - m_fCXBorder - kCornerEnlarge, |
257 m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); | 246 m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); |
258 if (rt.Contains(fx, fy)) { | 247 if (rt.Contains(fx, fy)) |
259 return FWL_WGTHITTEST_RightBottom; | 248 return FWL_WidgetHit::RightBottom; |
260 } | |
261 } | 249 } |
262 return FWL_WGTHITTEST_Client; | 250 return FWL_WidgetHit::Client; |
263 } | 251 } |
264 FWL_ERR CFWL_FormImp::DrawWidget(CFX_Graphics* pGraphics, | 252 FWL_ERR CFWL_FormImp::DrawWidget(CFX_Graphics* pGraphics, |
265 const CFX_Matrix* pMatrix) { | 253 const CFX_Matrix* pMatrix) { |
266 if (!pGraphics) | 254 if (!pGraphics) |
267 return FWL_ERR_Indefinite; | 255 return FWL_ERR_Indefinite; |
268 if (!m_pProperties->m_pThemeProvider) | 256 if (!m_pProperties->m_pThemeProvider) |
269 return FWL_ERR_Indefinite; | 257 return FWL_ERR_Indefinite; |
270 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 258 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
271 FX_BOOL bInactive = !IsActive(); | 259 FX_BOOL bInactive = !IsActive(); |
272 int32_t iState = bInactive ? CFWL_PartState_Inactive : CFWL_PartState_Normal; | 260 int32_t iState = bInactive ? CFWL_PartState_Inactive : CFWL_PartState_Normal; |
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 pHover->SetNormal(); | 1121 pHover->SetNormal(); |
1134 m_pOwner->Repaint(&pHover->m_rtBtn); | 1122 m_pOwner->Repaint(&pHover->m_rtBtn); |
1135 } | 1123 } |
1136 if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseLeave && | 1124 if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseLeave && |
1137 !m_pOwner->m_bLButtonDown) { | 1125 !m_pOwner->m_bLButtonDown) { |
1138 m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy); | 1126 m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy); |
1139 } | 1127 } |
1140 } | 1128 } |
1141 void CFWL_FormImpDelegate::OnLButtonDblClk(CFWL_MsgMouse* pMsg) { | 1129 void CFWL_FormImpDelegate::OnLButtonDblClk(CFWL_MsgMouse* pMsg) { |
1142 if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && | 1130 if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && |
1143 m_pOwner->HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WGTHITTEST_Titlebar) { | 1131 m_pOwner->HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WidgetHit::Titlebar) { |
1144 if (m_pOwner->m_bMaximized) { | 1132 if (m_pOwner->m_bMaximized) { |
1145 m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore); | 1133 m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore); |
1146 } else { | 1134 } else { |
1147 m_pOwner->SetWorkAreaRect(); | 1135 m_pOwner->SetWorkAreaRect(); |
1148 } | 1136 } |
1149 m_pOwner->Update(); | 1137 m_pOwner->Update(); |
1150 m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized; | 1138 m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized; |
1151 } | 1139 } |
1152 } | 1140 } |
1153 void CFWL_FormImpDelegate::OnWindowMove(CFWL_MsgWindowMove* pMsg) { | 1141 void CFWL_FormImpDelegate::OnWindowMove(CFWL_MsgWindowMove* pMsg) { |
1154 m_pOwner->m_pProperties->m_rtWidget.left = pMsg->m_fx; | 1142 m_pOwner->m_pProperties->m_rtWidget.left = pMsg->m_fx; |
1155 m_pOwner->m_pProperties->m_rtWidget.top = pMsg->m_fy; | 1143 m_pOwner->m_pProperties->m_rtWidget.top = pMsg->m_fy; |
1156 } | 1144 } |
1157 void CFWL_FormImpDelegate::OnClose(CFWL_MsgClose* pMsg) { | 1145 void CFWL_FormImpDelegate::OnClose(CFWL_MsgClose* pMsg) { |
1158 CFWL_EvtClose eClose; | 1146 CFWL_EvtClose eClose; |
1159 eClose.m_pSrcTarget = m_pOwner->m_pInterface; | 1147 eClose.m_pSrcTarget = m_pOwner->m_pInterface; |
1160 m_pOwner->DispatchEvent(&eClose); | 1148 m_pOwner->DispatchEvent(&eClose); |
1161 } | 1149 } |
OLD | NEW |