| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 FWL_Type CFWL_Form::GetClassID() const { | 73 FWL_Type CFWL_Form::GetClassID() const { |
| 74 return FWL_Type::Form; | 74 return FWL_Type::Form; |
| 75 } | 75 } |
| 76 | 76 |
| 77 bool CFWL_Form::IsInstance(const CFX_WideStringC& wsClass) const { | 77 bool CFWL_Form::IsInstance(const CFX_WideStringC& wsClass) const { |
| 78 if (wsClass == CFX_WideStringC(FWL_CLASS_Form)) | 78 if (wsClass == CFX_WideStringC(FWL_CLASS_Form)) |
| 79 return true; | 79 return true; |
| 80 return CFWL_Widget::IsInstance(wsClass); | 80 return CFWL_Widget::IsInstance(wsClass); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void CFWL_Form::GetClientRect(CFX_RectF& rect) { | 83 CFX_RectF CFWL_Form::GetClientRect() { |
| 84 rect = m_pProperties->m_rtWidget; | 84 CFX_RectF rect = m_pProperties->m_rtWidget; |
| 85 rect.Offset(-rect.left, -rect.top); | 85 rect.Offset(-rect.left, -rect.top); |
| 86 return rect; |
| 86 } | 87 } |
| 87 | 88 |
| 88 void CFWL_Form::Update() { | 89 void CFWL_Form::Update() { |
| 89 if (m_iLock > 0) | 90 if (m_iLock > 0) |
| 90 return; | 91 return; |
| 91 if (!m_pProperties->m_pThemeProvider) | 92 if (!m_pProperties->m_pThemeProvider) |
| 92 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 93 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 93 | 94 |
| 94 Layout(); | 95 Layout(); |
| 95 } | 96 } |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 } | 378 } |
| 378 } | 379 } |
| 379 | 380 |
| 380 void CFWL_Form::SetWorkAreaRect() { | 381 void CFWL_Form::SetWorkAreaRect() { |
| 381 m_rtRestore = m_pProperties->m_rtWidget; | 382 m_rtRestore = m_pProperties->m_rtWidget; |
| 382 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); | 383 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); |
| 383 if (!pWidgetMgr) | 384 if (!pWidgetMgr) |
| 384 return; | 385 return; |
| 385 | 386 |
| 386 m_bSetMaximize = true; | 387 m_bSetMaximize = true; |
| 387 Repaint(&m_rtRelative); | 388 RepaintRect(m_rtRelative); |
| 388 } | 389 } |
| 389 | 390 |
| 390 void CFWL_Form::Layout() { | 391 void CFWL_Form::Layout() { |
| 391 GetRelativeRect(m_rtRelative); | 392 m_rtRelative = GetRelativeRect(); |
| 392 | 393 |
| 393 #ifndef FWL_UseMacSystemBorder | 394 #ifndef FWL_UseMacSystemBorder |
| 394 ResetSysBtn(); | 395 ResetSysBtn(); |
| 395 #endif | 396 #endif |
| 396 } | 397 } |
| 397 | 398 |
| 398 void CFWL_Form::ResetSysBtn() { | 399 void CFWL_Form::ResetSysBtn() { |
| 399 m_fCXBorder = | 400 m_fCXBorder = |
| 400 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CXBorder)); | 401 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CXBorder)); |
| 401 m_fCYBorder = | 402 m_fCYBorder = |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 SetGrab(true); | 513 SetGrab(true); |
| 513 m_bLButtonDown = true; | 514 m_bLButtonDown = true; |
| 514 | 515 |
| 515 CFWL_SysBtn* pPressBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); | 516 CFWL_SysBtn* pPressBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); |
| 516 m_iCaptureBtn = GetSysBtnIndex(pPressBtn); | 517 m_iCaptureBtn = GetSysBtnIndex(pPressBtn); |
| 517 | 518 |
| 518 if (!pPressBtn) | 519 if (!pPressBtn) |
| 519 return; | 520 return; |
| 520 | 521 |
| 521 pPressBtn->SetPressed(); | 522 pPressBtn->SetPressed(); |
| 522 Repaint(&pPressBtn->m_rtBtn); | 523 RepaintRect(pPressBtn->m_rtBtn); |
| 523 } | 524 } |
| 524 | 525 |
| 525 void CFWL_Form::OnLButtonUp(CFWL_MessageMouse* pMsg) { | 526 void CFWL_Form::OnLButtonUp(CFWL_MessageMouse* pMsg) { |
| 526 SetGrab(false); | 527 SetGrab(false); |
| 527 m_bLButtonDown = false; | 528 m_bLButtonDown = false; |
| 528 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); | 529 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); |
| 529 CFWL_SysBtn* pPressedBtn = GetSysBtnByIndex(m_iCaptureBtn); | 530 CFWL_SysBtn* pPressedBtn = GetSysBtnByIndex(m_iCaptureBtn); |
| 530 if (!pPressedBtn || pPointBtn != pPressedBtn) | 531 if (!pPressedBtn || pPointBtn != pPressedBtn) |
| 531 return; | 532 return; |
| 532 if (pPressedBtn == GetSysBtnByState(FWL_SYSBUTTONSTATE_Pressed)) | 533 if (pPressedBtn == GetSysBtnByState(FWL_SYSBUTTONSTATE_Pressed)) |
| 533 pPressedBtn->SetNormal(); | 534 pPressedBtn->SetNormal(); |
| 534 if (pPressedBtn == m_pMaxBox) { | 535 if (pPressedBtn == m_pMaxBox) { |
| 535 if (m_bMaximized) { | 536 if (m_bMaximized) { |
| 536 SetWidgetRect(m_rtRestore); | 537 SetWidgetRect(m_rtRestore); |
| 537 Update(); | 538 Update(); |
| 538 Repaint(nullptr); | 539 Repaint(); |
| 539 } else { | 540 } else { |
| 540 SetWorkAreaRect(); | 541 SetWorkAreaRect(); |
| 541 Update(); | 542 Update(); |
| 542 } | 543 } |
| 543 m_bMaximized = !m_bMaximized; | 544 m_bMaximized = !m_bMaximized; |
| 544 } else if (pPressedBtn != m_pMinBox) { | 545 } else if (pPressedBtn != m_pMinBox) { |
| 545 CFWL_Event eClose(CFWL_Event::Type::Close, this); | 546 CFWL_Event eClose(CFWL_Event::Type::Close, this); |
| 546 DispatchEvent(&eClose); | 547 DispatchEvent(&eClose); |
| 547 } | 548 } |
| 548 } | 549 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 pPointBtn->SetHover(); | 592 pPointBtn->SetHover(); |
| 592 if (rtInvalidate.IsEmpty()) | 593 if (rtInvalidate.IsEmpty()) |
| 593 rtInvalidate = pPointBtn->m_rtBtn; | 594 rtInvalidate = pPointBtn->m_rtBtn; |
| 594 else | 595 else |
| 595 rtInvalidate.Union(pPointBtn->m_rtBtn); | 596 rtInvalidate.Union(pPointBtn->m_rtBtn); |
| 596 } | 597 } |
| 597 } | 598 } |
| 598 #endif | 599 #endif |
| 599 | 600 |
| 600 if (!rtInvalidate.IsEmpty()) | 601 if (!rtInvalidate.IsEmpty()) |
| 601 Repaint(&rtInvalidate); | 602 RepaintRect(rtInvalidate); |
| 602 } | 603 } |
| 603 | 604 |
| 604 void CFWL_Form::OnMouseLeave(CFWL_MessageMouse* pMsg) { | 605 void CFWL_Form::OnMouseLeave(CFWL_MessageMouse* pMsg) { |
| 605 CFWL_SysBtn* pHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); | 606 CFWL_SysBtn* pHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); |
| 606 if (!pHover) | 607 if (!pHover) |
| 607 return; | 608 return; |
| 608 | 609 |
| 609 pHover->SetNormal(); | 610 pHover->SetNormal(); |
| 610 Repaint(&pHover->m_rtBtn); | 611 RepaintRect(pHover->m_rtBtn); |
| 611 } | 612 } |
| 612 | 613 |
| 613 void CFWL_Form::OnLButtonDblClk(CFWL_MessageMouse* pMsg) { | 614 void CFWL_Form::OnLButtonDblClk(CFWL_MessageMouse* pMsg) { |
| 614 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && | 615 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && |
| 615 HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WidgetHit::Titlebar) { | 616 HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WidgetHit::Titlebar) { |
| 616 if (m_bMaximized) | 617 if (m_bMaximized) |
| 617 SetWidgetRect(m_rtRestore); | 618 SetWidgetRect(m_rtRestore); |
| 618 else | 619 else |
| 619 SetWorkAreaRect(); | 620 SetWorkAreaRect(); |
| 620 | 621 |
| 621 Update(); | 622 Update(); |
| 622 m_bMaximized = !m_bMaximized; | 623 m_bMaximized = !m_bMaximized; |
| 623 } | 624 } |
| 624 } | 625 } |
| OLD | NEW |