| 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 23 matching lines...) Expand all Loading... |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 RestoreInfo::RestoreInfo() {} | 36 RestoreInfo::RestoreInfo() {} |
| 37 | 37 |
| 38 RestoreInfo::~RestoreInfo() {} | 38 RestoreInfo::~RestoreInfo() {} |
| 39 | 39 |
| 40 IFWL_Form::IFWL_Form(const IFWL_App* app, | 40 IFWL_Form::IFWL_Form(const IFWL_App* app, |
| 41 std::unique_ptr<CFWL_WidgetProperties> properties, | 41 std::unique_ptr<CFWL_WidgetProperties> properties, |
| 42 IFWL_Widget* pOuter) | 42 IFWL_Widget* pOuter) |
| 43 : IFWL_Widget(app, std::move(properties), pOuter), | 43 : IFWL_Widget(app, std::move(properties), pOuter), |
| 44 #if (_FX_OS_ == _FX_MACOSX_) |
| 45 m_bMouseIn(false), |
| 46 #endif |
| 44 m_pCloseBox(nullptr), | 47 m_pCloseBox(nullptr), |
| 45 m_pMinBox(nullptr), | 48 m_pMinBox(nullptr), |
| 46 m_pMaxBox(nullptr), | 49 m_pMaxBox(nullptr), |
| 47 m_pCaptionBox(nullptr), | 50 m_pCaptionBox(nullptr), |
| 48 m_pSubFocus(nullptr), | 51 m_pSubFocus(nullptr), |
| 49 m_fCXBorder(0), | 52 m_fCXBorder(0), |
| 50 m_fCYBorder(0), | 53 m_fCYBorder(0), |
| 51 m_iCaptureBtn(-1), | 54 m_iCaptureBtn(-1), |
| 52 m_iSysBox(0), | 55 m_iSysBox(0), |
| 53 m_eResizeType(FORM_RESIZETYPE_None), | 56 m_eResizeType(FORM_RESIZETYPE_None), |
| 54 m_bLButtonDown(false), | 57 m_bLButtonDown(false), |
| 55 m_bMaximized(false), | 58 m_bMaximized(false), |
| 56 m_bSetMaximize(false), | 59 m_bSetMaximize(false), |
| 57 m_bCustomizeLayout(false), | 60 m_bCustomizeLayout(false), |
| 58 m_eFormSize(FWL_FORMSIZE_Manual), | |
| 59 m_bDoModalFlag(false), | 61 m_bDoModalFlag(false), |
| 60 m_pBigIcon(nullptr), | 62 m_pBigIcon(nullptr), |
| 61 m_pSmallIcon(nullptr), | 63 m_pSmallIcon(nullptr) { |
| 62 m_bMouseIn(false) { | |
| 63 m_rtRelative.Reset(); | 64 m_rtRelative.Reset(); |
| 64 m_rtCaption.Reset(); | 65 m_rtCaption.Reset(); |
| 65 m_rtRestore.Reset(); | 66 m_rtRestore.Reset(); |
| 66 m_rtCaptionText.Reset(); | 67 m_rtCaptionText.Reset(); |
| 67 m_rtIcon.Reset(); | 68 m_rtIcon.Reset(); |
| 68 | 69 |
| 69 RegisterForm(); | 70 RegisterForm(); |
| 70 RegisterEventTarget(); | 71 RegisterEventTarget(); |
| 71 } | 72 } |
| 72 | 73 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 if (m_pMinBox) { | 313 if (m_pMinBox) { |
| 313 param.m_iPart = CFWL_Part::MinimizeBox; | 314 param.m_iPart = CFWL_Part::MinimizeBox; |
| 314 param.m_dwStates = m_pMinBox->GetPartState(); | 315 param.m_dwStates = m_pMinBox->GetPartState(); |
| 315 param.m_rtPart = m_pMinBox->m_rtBtn; | 316 param.m_rtPart = m_pMinBox->m_rtBtn; |
| 316 pTheme->DrawBackground(¶m); | 317 pTheme->DrawBackground(¶m); |
| 317 } | 318 } |
| 318 } | 319 } |
| 319 #endif | 320 #endif |
| 320 } | 321 } |
| 321 | 322 |
| 322 FWL_FORMSIZE IFWL_Form::GetFormSize() { | |
| 323 return m_eFormSize; | |
| 324 } | |
| 325 | |
| 326 FWL_Error IFWL_Form::SetFormSize(FWL_FORMSIZE eFormSize) { | |
| 327 m_eFormSize = eFormSize; | |
| 328 return FWL_Error::Succeeded; | |
| 329 } | |
| 330 | |
| 331 IFWL_Widget* IFWL_Form::DoModal() { | 323 IFWL_Widget* IFWL_Form::DoModal() { |
| 332 const IFWL_App* pApp = GetOwnerApp(); | 324 const IFWL_App* pApp = GetOwnerApp(); |
| 333 if (!pApp) | 325 if (!pApp) |
| 334 return nullptr; | 326 return nullptr; |
| 335 | 327 |
| 336 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); | 328 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); |
| 337 if (!pDriver) | 329 if (!pDriver) |
| 338 return nullptr; | 330 return nullptr; |
| 339 | 331 |
| 340 m_pNoteLoop.reset(new CFWL_NoteLoop(this)); | 332 m_pNoteLoop.reset(new CFWL_NoteLoop(this)); |
| 341 pDriver->PushNoteLoop(m_pNoteLoop.get()); | 333 pDriver->PushNoteLoop(m_pNoteLoop.get()); |
| 342 m_bDoModalFlag = true; | 334 m_bDoModalFlag = true; |
| 343 SetStates(FWL_WGTSTATE_Invisible, false); | 335 SetStates(FWL_WGTSTATE_Invisible, false); |
| 344 pDriver->Run(); | 336 pDriver->Run(); |
| 345 #if (_FX_OS_ == _FX_MACOSX_) | 337 #if (_FX_OS_ == _FX_MACOSX_) |
| 346 #else | 338 #else |
| 347 pDriver->PopNoteLoop(); | 339 pDriver->PopNoteLoop(); |
| 348 #endif | 340 #endif |
| 349 m_pNoteLoop.reset(); | 341 m_pNoteLoop.reset(); |
| 350 return nullptr; | 342 return nullptr; |
| 351 } | 343 } |
| 352 | 344 |
| 353 IFWL_Widget* IFWL_Form::DoModal(uint32_t& dwCommandID) { | 345 void IFWL_Form::EndDoModal() { |
| 354 return DoModal(); | |
| 355 } | |
| 356 | |
| 357 FWL_Error IFWL_Form::EndDoModal() { | |
| 358 if (!m_pNoteLoop) | 346 if (!m_pNoteLoop) |
| 359 return FWL_Error::Indefinite; | 347 return; |
| 360 m_bDoModalFlag = false; | 348 m_bDoModalFlag = false; |
| 361 #if (_FX_OS_ == _FX_MACOSX_) | 349 #if (_FX_OS_ == _FX_MACOSX_) |
| 362 m_pNoteLoop->EndModalLoop(); | 350 m_pNoteLoop->EndModalLoop(); |
| 363 const IFWL_App* pApp = GetOwnerApp(); | 351 const IFWL_App* pApp = GetOwnerApp(); |
| 364 if (!pApp) | 352 if (!pApp) |
| 365 return FWL_Error::Indefinite; | 353 return; |
| 366 | 354 |
| 367 CFWL_NoteDriver* pDriver = | 355 CFWL_NoteDriver* pDriver = |
| 368 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 356 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
| 369 if (!pDriver) | 357 if (!pDriver) |
| 370 return FWL_Error::Indefinite; | 358 return; |
| 371 | 359 |
| 372 pDriver->PopNoteLoop(); | 360 pDriver->PopNoteLoop(); |
| 373 SetStates(FWL_WGTSTATE_Invisible, true); | 361 SetStates(FWL_WGTSTATE_Invisible, true); |
| 374 return FWL_Error::Succeeded; | |
| 375 #else | 362 #else |
| 376 SetStates(FWL_WGTSTATE_Invisible, true); | 363 SetStates(FWL_WGTSTATE_Invisible, true); |
| 377 return m_pNoteLoop->EndModalLoop(); | 364 m_pNoteLoop->EndModalLoop(); |
| 378 #endif | 365 #endif |
| 379 } | 366 } |
| 380 | 367 |
| 381 FWL_Error IFWL_Form::SetBorderRegion(CFX_Path* pPath) { | |
| 382 return FWL_Error::Succeeded; | |
| 383 } | |
| 384 void IFWL_Form::DrawBackground(CFX_Graphics* pGraphics, | 368 void IFWL_Form::DrawBackground(CFX_Graphics* pGraphics, |
| 385 IFWL_ThemeProvider* pTheme) { | 369 IFWL_ThemeProvider* pTheme) { |
| 386 CFWL_ThemeBackground param; | 370 CFWL_ThemeBackground param; |
| 387 param.m_pWidget = this; | 371 param.m_pWidget = this; |
| 388 param.m_iPart = CFWL_Part::Background; | 372 param.m_iPart = CFWL_Part::Background; |
| 389 param.m_pGraphics = pGraphics; | 373 param.m_pGraphics = pGraphics; |
| 390 param.m_rtPart = m_rtRelative; | 374 param.m_rtPart = m_rtRelative; |
| 391 param.m_rtPart.Deflate(m_fCYBorder, m_rtCaption.height, m_fCYBorder, | 375 param.m_rtPart.Deflate(m_fCYBorder, m_rtCaption.height, m_fCYBorder, |
| 392 m_fCXBorder); | 376 m_fCXBorder); |
| 393 pTheme->DrawBackground(¶m); | 377 pTheme->DrawBackground(¶m); |
| 394 } | 378 } |
| 395 IFWL_Widget* IFWL_Form::GetSubFocus() { | |
| 396 return m_pSubFocus; | |
| 397 } | |
| 398 void IFWL_Form::SetSubFocus(IFWL_Widget* pWidget) { | |
| 399 m_pSubFocus = pWidget; | |
| 400 } | |
| 401 | |
| 402 void IFWL_Form::ShowChildWidget(IFWL_Widget* pParent) { | |
| 403 const IFWL_App* pApp = pParent->GetOwnerApp(); | |
| 404 if (!pApp) | |
| 405 return; | |
| 406 | |
| 407 CFWL_WidgetMgr* pWidgetMgr = pApp->GetWidgetMgr(); | |
| 408 if (!pWidgetMgr) | |
| 409 return; | |
| 410 | |
| 411 IFWL_Widget* pChild = pWidgetMgr->GetFirstChildWidget(pParent); | |
| 412 while (pChild) { | |
| 413 ShowChildWidget(pChild); | |
| 414 pChild = pWidgetMgr->GetNextSiblingWidget(pChild); | |
| 415 } | |
| 416 } | |
| 417 | 379 |
| 418 void IFWL_Form::RemoveSysButtons() { | 380 void IFWL_Form::RemoveSysButtons() { |
| 419 m_rtCaption.Reset(); | 381 m_rtCaption.Reset(); |
| 420 delete m_pCloseBox; | 382 delete m_pCloseBox; |
| 421 m_pCloseBox = nullptr; | 383 m_pCloseBox = nullptr; |
| 422 delete m_pMinBox; | 384 delete m_pMinBox; |
| 423 m_pMinBox = nullptr; | 385 m_pMinBox = nullptr; |
| 424 delete m_pMaxBox; | 386 delete m_pMaxBox; |
| 425 m_pMaxBox = nullptr; | 387 m_pMaxBox = nullptr; |
| 426 delete m_pCaptionBox; | 388 delete m_pCaptionBox; |
| 427 m_pCaptionBox = nullptr; | 389 m_pCaptionBox = nullptr; |
| 428 } | 390 } |
| 429 | 391 |
| 430 void IFWL_Form::CalcContentRect(CFX_RectF& rtContent) { | |
| 431 #ifdef FWL_UseMacSystemBorder | |
| 432 rtContent = m_rtRelative; | |
| 433 #else | |
| 434 GetEdgeRect(rtContent); | |
| 435 if (HasEdge()) { | |
| 436 FX_FLOAT fEdge = GetEdgeWidth(); | |
| 437 rtContent.Deflate(fEdge, fEdge); | |
| 438 } | |
| 439 #endif | |
| 440 } | |
| 441 CFWL_SysBtn* IFWL_Form::GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy) { | 392 CFWL_SysBtn* IFWL_Form::GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy) { |
| 442 if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) { | 393 if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) { |
| 443 return m_pCloseBox; | 394 return m_pCloseBox; |
| 444 } | 395 } |
| 445 if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) { | 396 if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) { |
| 446 return m_pMaxBox; | 397 return m_pMaxBox; |
| 447 } | 398 } |
| 448 if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) { | 399 if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) { |
| 449 return m_pMinBox; | 400 return m_pMinBox; |
| 450 } | 401 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 } | 522 } |
| 572 } | 523 } |
| 573 void IFWL_Form::SetWorkAreaRect() { | 524 void IFWL_Form::SetWorkAreaRect() { |
| 574 m_rtRestore = m_pProperties->m_rtWidget; | 525 m_rtRestore = m_pProperties->m_rtWidget; |
| 575 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); | 526 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); |
| 576 if (!pWidgetMgr) | 527 if (!pWidgetMgr) |
| 577 return; | 528 return; |
| 578 m_bSetMaximize = true; | 529 m_bSetMaximize = true; |
| 579 Repaint(&m_rtRelative); | 530 Repaint(&m_rtRelative); |
| 580 } | 531 } |
| 581 void IFWL_Form::SetCursor(FX_FLOAT fx, FX_FLOAT fy) {} | 532 |
| 582 void IFWL_Form::Layout() { | 533 void IFWL_Form::Layout() { |
| 583 GetRelativeRect(m_rtRelative); | 534 GetRelativeRect(m_rtRelative); |
| 584 #ifndef FWL_UseMacSystemBorder | 535 #ifndef FWL_UseMacSystemBorder |
| 585 ReSetSysBtn(); | 536 ResetSysBtn(); |
| 586 #endif | 537 #endif |
| 587 } | 538 } |
| 588 void IFWL_Form::ReSetSysBtn() { | 539 void IFWL_Form::ResetSysBtn() { |
| 589 m_fCXBorder = | 540 m_fCXBorder = |
| 590 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CXBorder)); | 541 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CXBorder)); |
| 591 m_fCYBorder = | 542 m_fCYBorder = |
| 592 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CYBorder)); | 543 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CYBorder)); |
| 593 RemoveSysButtons(); | 544 RemoveSysButtons(); |
| 594 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 545 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
| 595 m_bCustomizeLayout = pTheme->IsCustomizedLayout(this); | 546 m_bCustomizeLayout = pTheme->IsCustomizedLayout(this); |
| 596 FX_FLOAT fCapHeight = GetCaptionHeight(); | 547 FX_FLOAT fCapHeight = GetCaptionHeight(); |
| 597 if (fCapHeight > 0) { | 548 if (fCapHeight > 0) { |
| 598 m_rtCaption = m_rtRelative; | 549 m_rtCaption = m_rtRelative; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 if (!pApp) | 620 if (!pApp) |
| 670 return; | 621 return; |
| 671 | 622 |
| 672 CFWL_NoteDriver* pDriver = | 623 CFWL_NoteDriver* pDriver = |
| 673 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 624 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
| 674 if (!pDriver) | 625 if (!pDriver) |
| 675 return; | 626 return; |
| 676 | 627 |
| 677 pDriver->UnRegisterForm(this); | 628 pDriver->UnRegisterForm(this); |
| 678 } | 629 } |
| 679 bool IFWL_Form::IsDoModal() { | 630 |
| 680 return m_bDoModalFlag; | |
| 681 } | |
| 682 void IFWL_Form::SetThemeData() { | 631 void IFWL_Form::SetThemeData() { |
| 683 m_fSmallIconSz = | 632 m_fSmallIconSz = |
| 684 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::SmallIcon)); | 633 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::SmallIcon)); |
| 685 m_fBigIconSz = | 634 m_fBigIconSz = |
| 686 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::BigIcon)); | 635 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::BigIcon)); |
| 687 } | 636 } |
| 688 bool IFWL_Form::HasIcon() { | 637 bool IFWL_Form::HasIcon() { |
| 689 IFWL_FormDP* pData = | 638 IFWL_FormDP* pData = |
| 690 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); | 639 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); |
| 691 return !!pData->GetIcon(this, false); | 640 return !!pData->GetIcon(this, false); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 706 void IFWL_Form::UpdateCaption() { | 655 void IFWL_Form::UpdateCaption() { |
| 707 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); | 656 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); |
| 708 if (!pWidgetMgr) | 657 if (!pWidgetMgr) |
| 709 return; | 658 return; |
| 710 IFWL_DataProvider* pData = m_pProperties->m_pDataProvider; | 659 IFWL_DataProvider* pData = m_pProperties->m_pDataProvider; |
| 711 if (!pData) | 660 if (!pData) |
| 712 return; | 661 return; |
| 713 CFX_WideString text; | 662 CFX_WideString text; |
| 714 pData->GetCaption(this, text); | 663 pData->GetCaption(this, text); |
| 715 } | 664 } |
| 716 void IFWL_Form::DoWidthLimit(FX_FLOAT& fLeft, | |
| 717 FX_FLOAT& fWidth, | |
| 718 FX_FLOAT fCurX, | |
| 719 FX_FLOAT fSpace, | |
| 720 FX_FLOAT fLimitMin, | |
| 721 FX_FLOAT fLimitMax, | |
| 722 bool bLeft) { | |
| 723 FX_FLOAT fx = fCurX; | |
| 724 FX_FLOAT fy = 0; | |
| 725 TransformTo(nullptr, fx, fy); | |
| 726 FX_FLOAT fTemp = | |
| 727 bLeft ? (fWidth - fx + fLeft + fSpace) : (fx - fLeft + fSpace); | |
| 728 if (fTemp >= fLimitMin && fTemp <= fLimitMax) { | |
| 729 fWidth = fTemp; | |
| 730 fLeft += bLeft ? (fx - fLeft - fSpace) : 0; | |
| 731 } else { | |
| 732 if (fTemp < fLimitMin && fWidth > fLimitMin) { | |
| 733 fLeft += bLeft ? (fWidth - fLimitMin) : 0; | |
| 734 fWidth = fLimitMin; | |
| 735 } else if (fTemp > fLimitMax && fWidth < fLimitMax) { | |
| 736 fLeft -= bLeft ? (fLimitMax - fWidth) : 0; | |
| 737 fWidth = fLimitMax; | |
| 738 } | |
| 739 } | |
| 740 } | |
| 741 void IFWL_Form::DoHeightLimit(FX_FLOAT& fTop, | |
| 742 FX_FLOAT& fHeight, | |
| 743 FX_FLOAT fCurY, | |
| 744 FX_FLOAT fSpace, | |
| 745 FX_FLOAT fLimitMin, | |
| 746 FX_FLOAT fLimitMax, | |
| 747 bool bTop) { | |
| 748 FX_FLOAT fx = 0; | |
| 749 FX_FLOAT fy = fCurY; | |
| 750 TransformTo(nullptr, fx, fy); | |
| 751 FX_FLOAT fTemp = bTop ? (fHeight - fy + fTop + fSpace) : (fy - fTop + fSpace); | |
| 752 if (fTemp >= fLimitMin && fTemp <= fLimitMax) { | |
| 753 fHeight = fTemp; | |
| 754 fTop += bTop ? (fy - fTop - fSpace) : 0; | |
| 755 } else { | |
| 756 if (fTemp < fLimitMin && fHeight > fLimitMin) { | |
| 757 fTop += bTop ? (fHeight - fLimitMin) : 0; | |
| 758 fHeight = fLimitMin; | |
| 759 } else if (fTemp > fLimitMax && fHeight < fLimitMax) { | |
| 760 fTop -= bTop ? (fLimitMax - fHeight) : 0; | |
| 761 fHeight = fLimitMax; | |
| 762 } | |
| 763 } | |
| 764 } | |
| 765 | 665 |
| 766 #ifdef FWL_UseMacSystemBorder | 666 #ifdef FWL_UseMacSystemBorder |
| 767 void IFWL_Form::OnProcessMessage(CFWL_Message* pMessage) { | 667 void IFWL_Form::OnProcessMessage(CFWL_Message* pMessage) { |
| 768 if (!pMessage) | 668 if (!pMessage) |
| 769 return; | 669 return; |
| 770 | 670 |
| 771 switch (pMessage->GetClassID()) { | 671 switch (pMessage->GetClassID()) { |
| 772 case CFWL_MessageType::Activate: { | 672 case CFWL_MessageType::Activate: { |
| 773 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated; | 673 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated; |
| 774 Repaint(&m_rtRelative); | 674 Repaint(&m_rtRelative); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 switch (pMsg->m_dwCmd) { | 725 switch (pMsg->m_dwCmd) { |
| 826 case FWL_MouseCommand::LeftButtonDown: | 726 case FWL_MouseCommand::LeftButtonDown: |
| 827 OnLButtonDown(pMsg); | 727 OnLButtonDown(pMsg); |
| 828 break; | 728 break; |
| 829 case FWL_MouseCommand::LeftButtonUp: | 729 case FWL_MouseCommand::LeftButtonUp: |
| 830 OnLButtonUp(pMsg); | 730 OnLButtonUp(pMsg); |
| 831 break; | 731 break; |
| 832 case FWL_MouseCommand::Move: | 732 case FWL_MouseCommand::Move: |
| 833 OnMouseMove(pMsg); | 733 OnMouseMove(pMsg); |
| 834 break; | 734 break; |
| 835 case FWL_MouseCommand::Hover: | |
| 836 OnMouseHover(pMsg); | |
| 837 break; | |
| 838 case FWL_MouseCommand::Leave: | 735 case FWL_MouseCommand::Leave: |
| 839 OnMouseLeave(pMsg); | 736 OnMouseLeave(pMsg); |
| 840 break; | 737 break; |
| 841 case FWL_MouseCommand::LeftButtonDblClk: | 738 case FWL_MouseCommand::LeftButtonDblClk: |
| 842 OnLButtonDblClk(pMsg); | 739 OnLButtonDblClk(pMsg); |
| 843 break; | 740 break; |
| 844 default: | 741 default: |
| 845 break; | 742 break; |
| 846 } | 743 } |
| 847 break; | 744 break; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 CFX_RectF rtCap; | 787 CFX_RectF rtCap; |
| 891 rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder, | 788 rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder, |
| 892 m_rtCaption.width - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder, | 789 m_rtCaption.width - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder, |
| 893 m_rtCaption.height - m_fCXBorder); | 790 m_rtCaption.height - m_fCXBorder); |
| 894 | 791 |
| 895 if (pPressBtn) { | 792 if (pPressBtn) { |
| 896 pPressBtn->SetPressed(); | 793 pPressBtn->SetPressed(); |
| 897 Repaint(&pPressBtn->m_rtBtn); | 794 Repaint(&pPressBtn->m_rtBtn); |
| 898 } else if (rtCap.Contains(pMsg->m_fx, pMsg->m_fy)) { | 795 } else if (rtCap.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| 899 m_eResizeType = FORM_RESIZETYPE_Cap; | 796 m_eResizeType = FORM_RESIZETYPE_Cap; |
| 900 } else if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && | |
| 901 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && | |
| 902 !m_bMaximized) { | |
| 903 SetCursor(pMsg->m_fx, pMsg->m_fy); | |
| 904 } | 797 } |
| 905 m_InfoStart.m_ptStart = CFX_PointF(pMsg->m_fx, pMsg->m_fy); | 798 m_InfoStart.m_ptStart = CFX_PointF(pMsg->m_fx, pMsg->m_fy); |
| 906 m_InfoStart.m_szStart = CFX_SizeF(m_pProperties->m_rtWidget.width, | 799 m_InfoStart.m_szStart = CFX_SizeF(m_pProperties->m_rtWidget.width, |
| 907 m_pProperties->m_rtWidget.height); | 800 m_pProperties->m_rtWidget.height); |
| 908 } | 801 } |
| 909 | 802 |
| 910 void IFWL_Form::OnLButtonUp(CFWL_MsgMouse* pMsg) { | 803 void IFWL_Form::OnLButtonUp(CFWL_MsgMouse* pMsg) { |
| 911 SetGrab(false); | 804 SetGrab(false); |
| 912 m_bLButtonDown = false; | 805 m_bLButtonDown = false; |
| 913 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); | 806 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 930 CFWL_EvtClose eClose; | 823 CFWL_EvtClose eClose; |
| 931 eClose.m_pSrcTarget = this; | 824 eClose.m_pSrcTarget = this; |
| 932 DispatchEvent(&eClose); | 825 DispatchEvent(&eClose); |
| 933 } | 826 } |
| 934 } | 827 } |
| 935 | 828 |
| 936 void IFWL_Form::OnMouseMove(CFWL_MsgMouse* pMsg) { | 829 void IFWL_Form::OnMouseMove(CFWL_MsgMouse* pMsg) { |
| 937 if (m_bLButtonDown) | 830 if (m_bLButtonDown) |
| 938 return; | 831 return; |
| 939 | 832 |
| 940 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && | |
| 941 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && | |
| 942 !m_bMaximized) { | |
| 943 SetCursor(pMsg->m_fx, pMsg->m_fy); | |
| 944 } | |
| 945 CFX_RectF rtInvalidate; | 833 CFX_RectF rtInvalidate; |
| 946 rtInvalidate.Reset(); | 834 rtInvalidate.Reset(); |
| 947 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); | 835 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); |
| 948 CFWL_SysBtn* pOldHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); | 836 CFWL_SysBtn* pOldHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); |
| 949 #if (_FX_OS_ == _FX_MACOSX_) | 837 #if (_FX_OS_ == _FX_MACOSX_) |
| 950 { | 838 { |
| 951 if (pOldHover && pPointBtn != pOldHover) | 839 if (pOldHover && pPointBtn != pOldHover) |
| 952 pOldHover->SetNormal(); | 840 pOldHover->SetNormal(); |
| 953 if (pPointBtn && pPointBtn != pOldHover) | 841 if (pPointBtn && pPointBtn != pOldHover) |
| 954 pPointBtn->SetHover(); | 842 pPointBtn->SetHover(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 983 rtInvalidate = pPointBtn->m_rtBtn; | 871 rtInvalidate = pPointBtn->m_rtBtn; |
| 984 else | 872 else |
| 985 rtInvalidate.Union(pPointBtn->m_rtBtn); | 873 rtInvalidate.Union(pPointBtn->m_rtBtn); |
| 986 } | 874 } |
| 987 } | 875 } |
| 988 #endif | 876 #endif |
| 989 if (!rtInvalidate.IsEmpty()) | 877 if (!rtInvalidate.IsEmpty()) |
| 990 Repaint(&rtInvalidate); | 878 Repaint(&rtInvalidate); |
| 991 } | 879 } |
| 992 | 880 |
| 993 void IFWL_Form::OnMouseHover(CFWL_MsgMouse* pMsg) { | |
| 994 SetCursor(pMsg->m_fx, pMsg->m_fy); | |
| 995 } | |
| 996 | |
| 997 void IFWL_Form::OnMouseLeave(CFWL_MsgMouse* pMsg) { | 881 void IFWL_Form::OnMouseLeave(CFWL_MsgMouse* pMsg) { |
| 998 CFWL_SysBtn* pHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); | 882 CFWL_SysBtn* pHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); |
| 999 if (pHover) { | 883 if (pHover) { |
| 1000 pHover->SetNormal(); | 884 pHover->SetNormal(); |
| 1001 Repaint(&pHover->m_rtBtn); | 885 Repaint(&pHover->m_rtBtn); |
| 1002 } | 886 } |
| 1003 if (pMsg->m_dwCmd == FWL_MouseCommand::Leave && !m_bLButtonDown) | |
| 1004 SetCursor(pMsg->m_fx, pMsg->m_fy); | |
| 1005 } | 887 } |
| 1006 | 888 |
| 1007 void IFWL_Form::OnLButtonDblClk(CFWL_MsgMouse* pMsg) { | 889 void IFWL_Form::OnLButtonDblClk(CFWL_MsgMouse* pMsg) { |
| 1008 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && | 890 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && |
| 1009 HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WidgetHit::Titlebar) { | 891 HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WidgetHit::Titlebar) { |
| 1010 if (m_bMaximized) | 892 if (m_bMaximized) |
| 1011 SetWidgetRect(m_rtRestore); | 893 SetWidgetRect(m_rtRestore); |
| 1012 else | 894 else |
| 1013 SetWorkAreaRect(); | 895 SetWorkAreaRect(); |
| 1014 | 896 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 | 940 |
| 1059 uint32_t CFWL_SysBtn::GetPartState() const { | 941 uint32_t CFWL_SysBtn::GetPartState() const { |
| 1060 if (IsDisabled()) | 942 if (IsDisabled()) |
| 1061 return CFWL_PartState_Disabled; | 943 return CFWL_PartState_Disabled; |
| 1062 if (m_dwState & FWL_SYSBUTTONSTATE_Pressed) | 944 if (m_dwState & FWL_SYSBUTTONSTATE_Pressed) |
| 1063 return CFWL_PartState_Pressed; | 945 return CFWL_PartState_Pressed; |
| 1064 if (m_dwState & FWL_SYSBUTTONSTATE_Hover) | 946 if (m_dwState & FWL_SYSBUTTONSTATE_Hover) |
| 1065 return CFWL_PartState_Hovered; | 947 return CFWL_PartState_Hovered; |
| 1066 return CFWL_PartState_Normal; | 948 return CFWL_PartState_Normal; |
| 1067 } | 949 } |
| OLD | NEW |