| 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/cfwl_form.h" | 7 #include "xfa/fwl/cfwl_form.h" | 
| 8 | 8 | 
| 9 #include <utility> | 9 #include <utility> | 
| 10 | 10 | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 25 #include "xfa/fwl/theme/cfwl_widgettp.h" | 25 #include "xfa/fwl/theme/cfwl_widgettp.h" | 
| 26 | 26 | 
| 27 namespace { | 27 namespace { | 
| 28 | 28 | 
| 29 const int kSystemButtonSize = 21; | 29 const int kSystemButtonSize = 21; | 
| 30 const int kSystemButtonMargin = 5; | 30 const int kSystemButtonMargin = 5; | 
| 31 const int kSystemButtonSpan = 2; | 31 const int kSystemButtonSpan = 2; | 
| 32 | 32 | 
| 33 }  // namespace | 33 }  // namespace | 
| 34 | 34 | 
| 35 namespace { |  | 
| 36 |  | 
| 37 const uint8_t kCornerEnlarge = 10; |  | 
| 38 |  | 
| 39 }  // namespace |  | 
| 40 |  | 
| 41 CFWL_Form::CFWL_Form(const CFWL_App* app, | 35 CFWL_Form::CFWL_Form(const CFWL_App* app, | 
| 42                      std::unique_ptr<CFWL_WidgetProperties> properties, | 36                      std::unique_ptr<CFWL_WidgetProperties> properties, | 
| 43                      CFWL_Widget* pOuter) | 37                      CFWL_Widget* pOuter) | 
| 44     : CFWL_Widget(app, std::move(properties), pOuter), | 38     : CFWL_Widget(app, std::move(properties), pOuter), | 
| 45 #if (_FX_OS_ == _FX_MACOSX_) | 39 #if (_FX_OS_ == _FX_MACOSX_) | 
| 46       m_bMouseIn(false), | 40       m_bMouseIn(false), | 
| 47 #endif | 41 #endif | 
| 48       m_pCloseBox(nullptr), | 42       m_pCloseBox(nullptr), | 
| 49       m_pMinBox(nullptr), | 43       m_pMinBox(nullptr), | 
| 50       m_pMaxBox(nullptr), | 44       m_pMaxBox(nullptr), | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 102     return FWL_WidgetHit::CloseBox; | 96     return FWL_WidgetHit::CloseBox; | 
| 103   if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) | 97   if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) | 
| 104     return FWL_WidgetHit::MaxBox; | 98     return FWL_WidgetHit::MaxBox; | 
| 105   if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) | 99   if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) | 
| 106     return FWL_WidgetHit::MinBox; | 100     return FWL_WidgetHit::MinBox; | 
| 107 | 101 | 
| 108   CFX_RectF rtCap; | 102   CFX_RectF rtCap; | 
| 109   rtCap.Set(m_fCYBorder, m_fCXBorder, | 103   rtCap.Set(m_fCYBorder, m_fCXBorder, | 
| 110             0 - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder, | 104             0 - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder, | 
| 111             0 - m_fCXBorder); | 105             0 - m_fCXBorder); | 
| 112   if (rtCap.Contains(fx, fy)) | 106   return rtCap.Contains(fx, fy) ? FWL_WidgetHit::Titlebar | 
| 113     return FWL_WidgetHit::Titlebar; | 107                                 : FWL_WidgetHit::Client; | 
| 114   if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && |  | 
| 115       (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize)) { |  | 
| 116     FX_FLOAT fWidth = m_rtRelative.width - 2 * (m_fCYBorder + kCornerEnlarge); |  | 
| 117     FX_FLOAT fHeight = m_rtRelative.height - 2 * (m_fCXBorder + kCornerEnlarge); |  | 
| 118 |  | 
| 119     CFX_RectF rt; |  | 
| 120     rt.Set(0, m_fCXBorder + kCornerEnlarge, m_fCYBorder, fHeight); |  | 
| 121     if (rt.Contains(fx, fy)) |  | 
| 122       return FWL_WidgetHit::Left; |  | 
| 123 |  | 
| 124     rt.Set(m_rtRelative.width - m_fCYBorder, m_fCXBorder + kCornerEnlarge, |  | 
| 125            m_fCYBorder, fHeight); |  | 
| 126     if (rt.Contains(fx, fy)) |  | 
| 127       return FWL_WidgetHit::Right; |  | 
| 128 |  | 
| 129     rt.Set(m_fCYBorder + kCornerEnlarge, 0, fWidth, m_fCXBorder); |  | 
| 130     if (rt.Contains(fx, fy)) |  | 
| 131       return FWL_WidgetHit::Top; |  | 
| 132 |  | 
| 133     rt.Set(m_fCYBorder + kCornerEnlarge, m_rtRelative.height - m_fCXBorder, |  | 
| 134            fWidth, m_fCXBorder); |  | 
| 135     if (rt.Contains(fx, fy)) |  | 
| 136       return FWL_WidgetHit::Bottom; |  | 
| 137 |  | 
| 138     rt.Set(0, 0, m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); |  | 
| 139     if (rt.Contains(fx, fy)) |  | 
| 140       return FWL_WidgetHit::LeftTop; |  | 
| 141 |  | 
| 142     rt.Set(0, m_rtRelative.height - m_fCXBorder - kCornerEnlarge, |  | 
| 143            m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); |  | 
| 144     if (rt.Contains(fx, fy)) |  | 
| 145       return FWL_WidgetHit::LeftBottom; |  | 
| 146 |  | 
| 147     rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge, 0, |  | 
| 148            m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); |  | 
| 149     if (rt.Contains(fx, fy)) |  | 
| 150       return FWL_WidgetHit::RightTop; |  | 
| 151 |  | 
| 152     rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge, |  | 
| 153            m_rtRelative.height - m_fCXBorder - kCornerEnlarge, |  | 
| 154            m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); |  | 
| 155     if (rt.Contains(fx, fy)) |  | 
| 156       return FWL_WidgetHit::RightBottom; |  | 
| 157   } |  | 
| 158   return FWL_WidgetHit::Client; |  | 
| 159 } | 108 } | 
| 160 | 109 | 
| 161 void CFWL_Form::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { | 110 void CFWL_Form::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { | 
| 162   if (!pGraphics) | 111   if (!pGraphics) | 
| 163     return; | 112     return; | 
| 164   if (!m_pProperties->m_pThemeProvider) | 113   if (!m_pProperties->m_pThemeProvider) | 
| 165     return; | 114     return; | 
| 166 | 115 | 
| 167   IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 116   IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 
| 168   bool bInactive = !IsActive(); | 117   bool bInactive = !IsActive(); | 
| 169   int32_t iState = bInactive ? CFWL_PartState_Inactive : CFWL_PartState_Normal; | 118   int32_t iState = bInactive ? CFWL_PartState_Inactive : CFWL_PartState_Normal; | 
| 170   if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_NoDrawClient) == 0) | 119   DrawBackground(pGraphics, pTheme); | 
| 171     DrawBackground(pGraphics, pTheme); |  | 
| 172 | 120 | 
| 173 #ifdef FWL_UseMacSystemBorder | 121 #ifdef FWL_UseMacSystemBorder | 
| 174   return; | 122   return; | 
| 175 #endif | 123 #endif | 
| 176   CFWL_ThemeBackground param; | 124   CFWL_ThemeBackground param; | 
| 177   param.m_pWidget = this; | 125   param.m_pWidget = this; | 
| 178   param.m_dwStates = iState; | 126   param.m_dwStates = iState; | 
| 179   param.m_pGraphics = pGraphics; | 127   param.m_pGraphics = pGraphics; | 
| 180   param.m_rtPart = m_rtRelative; | 128   param.m_rtPart = m_rtRelative; | 
| 181   if (pMatrix) | 129   if (pMatrix) | 
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 482           break; | 430           break; | 
| 483         case FWL_MouseCommand::LeftButtonUp: | 431         case FWL_MouseCommand::LeftButtonUp: | 
| 484           OnLButtonUp(pMsg); | 432           OnLButtonUp(pMsg); | 
| 485           break; | 433           break; | 
| 486         case FWL_MouseCommand::Move: | 434         case FWL_MouseCommand::Move: | 
| 487           OnMouseMove(pMsg); | 435           OnMouseMove(pMsg); | 
| 488           break; | 436           break; | 
| 489         case FWL_MouseCommand::Leave: | 437         case FWL_MouseCommand::Leave: | 
| 490           OnMouseLeave(pMsg); | 438           OnMouseLeave(pMsg); | 
| 491           break; | 439           break; | 
| 492         case FWL_MouseCommand::LeftButtonDblClk: |  | 
| 493           OnLButtonDblClk(pMsg); |  | 
| 494           break; |  | 
| 495         default: | 440         default: | 
| 496           break; | 441           break; | 
| 497       } | 442       } | 
| 498       break; | 443       break; | 
| 499     } | 444     } | 
| 500     default: | 445     default: | 
| 501       break; | 446       break; | 
| 502   } | 447   } | 
| 503 #endif  // FWL_UseMacSystemBorder | 448 #endif  // FWL_UseMacSystemBorder | 
| 504 } | 449 } | 
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 602 } | 547 } | 
| 603 | 548 | 
| 604 void CFWL_Form::OnMouseLeave(CFWL_MessageMouse* pMsg) { | 549 void CFWL_Form::OnMouseLeave(CFWL_MessageMouse* pMsg) { | 
| 605   CFWL_SysBtn* pHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); | 550   CFWL_SysBtn* pHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); | 
| 606   if (!pHover) | 551   if (!pHover) | 
| 607     return; | 552     return; | 
| 608 | 553 | 
| 609   pHover->SetNormal(); | 554   pHover->SetNormal(); | 
| 610   RepaintRect(pHover->m_rtBtn); | 555   RepaintRect(pHover->m_rtBtn); | 
| 611 } | 556 } | 
| 612 |  | 
| 613 void CFWL_Form::OnLButtonDblClk(CFWL_MessageMouse* pMsg) { |  | 
| 614   if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && |  | 
| 615       HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WidgetHit::Titlebar) { |  | 
| 616     if (m_bMaximized) |  | 
| 617       SetWidgetRect(m_rtRestore); |  | 
| 618     else |  | 
| 619       SetWorkAreaRect(); |  | 
| 620 |  | 
| 621     Update(); |  | 
| 622     m_bMaximized = !m_bMaximized; |  | 
| 623   } |  | 
| 624 } |  | 
| OLD | NEW | 
|---|