| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 m_pCloseBox(nullptr), | 44 m_pCloseBox(nullptr), |
| 45 m_pMinBox(nullptr), | 45 m_pMinBox(nullptr), |
| 46 m_pMaxBox(nullptr), | 46 m_pMaxBox(nullptr), |
| 47 m_pCaptionBox(nullptr), | 47 m_pCaptionBox(nullptr), |
| 48 m_pSubFocus(nullptr), | 48 m_pSubFocus(nullptr), |
| 49 m_fCXBorder(0), | 49 m_fCXBorder(0), |
| 50 m_fCYBorder(0), | 50 m_fCYBorder(0), |
| 51 m_iCaptureBtn(-1), | 51 m_iCaptureBtn(-1), |
| 52 m_iSysBox(0), | 52 m_iSysBox(0), |
| 53 m_eResizeType(FORM_RESIZETYPE_None), | 53 m_eResizeType(FORM_RESIZETYPE_None), |
| 54 m_bLButtonDown(FALSE), | 54 m_bLButtonDown(false), |
| 55 m_bMaximized(false), | 55 m_bMaximized(false), |
| 56 m_bSetMaximize(FALSE), | 56 m_bSetMaximize(false), |
| 57 m_bCustomizeLayout(false), | 57 m_bCustomizeLayout(false), |
| 58 m_eFormSize(FWL_FORMSIZE_Manual), | 58 m_eFormSize(FWL_FORMSIZE_Manual), |
| 59 m_bDoModalFlag(FALSE), | 59 m_bDoModalFlag(false), |
| 60 m_pBigIcon(nullptr), | 60 m_pBigIcon(nullptr), |
| 61 m_pSmallIcon(nullptr), | 61 m_pSmallIcon(nullptr), |
| 62 m_bMouseIn(FALSE) { | 62 m_bMouseIn(false) { |
| 63 m_rtRelative.Reset(); | 63 m_rtRelative.Reset(); |
| 64 m_rtCaption.Reset(); | 64 m_rtCaption.Reset(); |
| 65 m_rtRestore.Reset(); | 65 m_rtRestore.Reset(); |
| 66 m_rtCaptionText.Reset(); | 66 m_rtCaptionText.Reset(); |
| 67 m_rtIcon.Reset(); | 67 m_rtIcon.Reset(); |
| 68 | 68 |
| 69 RegisterForm(); | 69 RegisterForm(); |
| 70 RegisterEventTarget(); | 70 RegisterEventTarget(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 IFWL_Form::~IFWL_Form() { | 73 IFWL_Form::~IFWL_Form() { |
| 74 UnregisterEventTarget(); | 74 UnregisterEventTarget(); |
| 75 UnRegisterForm(); | 75 UnRegisterForm(); |
| 76 RemoveSysButtons(); | 76 RemoveSysButtons(); |
| 77 } | 77 } |
| 78 | 78 |
| 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 FX_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, FX_BOOL bAutoSize) { | 89 FWL_Error 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; | 101 return FWL_Error::Succeeded; |
| 102 } | 102 } |
| 103 FWL_Error IFWL_Form::GetClientRect(CFX_RectF& rect) { | 103 FWL_Error IFWL_Form::GetClientRect(CFX_RectF& rect) { |
| 104 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) == 0) { | 104 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) == 0) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 } | 206 } |
| 207 return FWL_WidgetHit::Client; | 207 return FWL_WidgetHit::Client; |
| 208 } | 208 } |
| 209 FWL_Error IFWL_Form::DrawWidget(CFX_Graphics* pGraphics, | 209 FWL_Error IFWL_Form::DrawWidget(CFX_Graphics* pGraphics, |
| 210 const CFX_Matrix* pMatrix) { | 210 const CFX_Matrix* pMatrix) { |
| 211 if (!pGraphics) | 211 if (!pGraphics) |
| 212 return FWL_Error::Indefinite; | 212 return FWL_Error::Indefinite; |
| 213 if (!m_pProperties->m_pThemeProvider) | 213 if (!m_pProperties->m_pThemeProvider) |
| 214 return FWL_Error::Indefinite; | 214 return FWL_Error::Indefinite; |
| 215 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 215 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
| 216 FX_BOOL bInactive = !IsActive(); | 216 bool bInactive = !IsActive(); |
| 217 int32_t iState = bInactive ? CFWL_PartState_Inactive : CFWL_PartState_Normal; | 217 int32_t iState = bInactive ? CFWL_PartState_Inactive : CFWL_PartState_Normal; |
| 218 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_NoDrawClient) == 0) { | 218 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_NoDrawClient) == 0) { |
| 219 DrawBackground(pGraphics, pTheme); | 219 DrawBackground(pGraphics, pTheme); |
| 220 } | 220 } |
| 221 #ifdef FWL_UseMacSystemBorder | 221 #ifdef FWL_UseMacSystemBorder |
| 222 return FWL_Error::Succeeded; | 222 return FWL_Error::Succeeded; |
| 223 #endif | 223 #endif |
| 224 CFWL_ThemeBackground param; | 224 CFWL_ThemeBackground param; |
| 225 param.m_pWidget = this; | 225 param.m_pWidget = this; |
| 226 param.m_dwStates = iState; | 226 param.m_dwStates = iState; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 param.m_iPart = CFWL_Part::MinimizeBox; | 290 param.m_iPart = CFWL_Part::MinimizeBox; |
| 291 param.m_dwStates = m_pMinBox->GetPartState(); | 291 param.m_dwStates = m_pMinBox->GetPartState(); |
| 292 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) { | 292 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) { |
| 293 param.m_dwStates = CFWL_PartState_Disabled; | 293 param.m_dwStates = CFWL_PartState_Disabled; |
| 294 } else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn) { | 294 } else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn) { |
| 295 param.m_dwStates = CFWL_PartState_Hovered; | 295 param.m_dwStates = CFWL_PartState_Hovered; |
| 296 } | 296 } |
| 297 param.m_rtPart = m_pMinBox->m_rtBtn; | 297 param.m_rtPart = m_pMinBox->m_rtBtn; |
| 298 pTheme->DrawBackground(¶m); | 298 pTheme->DrawBackground(¶m); |
| 299 } | 299 } |
| 300 m_bMouseIn = FALSE; | 300 m_bMouseIn = false; |
| 301 } | 301 } |
| 302 #else | 302 #else |
| 303 { | 303 { |
| 304 if (m_pCloseBox) { | 304 if (m_pCloseBox) { |
| 305 param.m_iPart = CFWL_Part::CloseBox; | 305 param.m_iPart = CFWL_Part::CloseBox; |
| 306 param.m_dwStates = m_pCloseBox->GetPartState(); | 306 param.m_dwStates = m_pCloseBox->GetPartState(); |
| 307 param.m_rtPart = m_pCloseBox->m_rtBtn; | 307 param.m_rtPart = m_pCloseBox->m_rtBtn; |
| 308 pTheme->DrawBackground(¶m); | 308 pTheme->DrawBackground(¶m); |
| 309 } | 309 } |
| 310 if (m_pMaxBox) { | 310 if (m_pMaxBox) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 338 const IFWL_App* pApp = GetOwnerApp(); | 338 const IFWL_App* pApp = GetOwnerApp(); |
| 339 if (!pApp) | 339 if (!pApp) |
| 340 return nullptr; | 340 return nullptr; |
| 341 | 341 |
| 342 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); | 342 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); |
| 343 if (!pDriver) | 343 if (!pDriver) |
| 344 return nullptr; | 344 return nullptr; |
| 345 | 345 |
| 346 m_pNoteLoop.reset(new CFWL_NoteLoop(this)); | 346 m_pNoteLoop.reset(new CFWL_NoteLoop(this)); |
| 347 pDriver->PushNoteLoop(m_pNoteLoop.get()); | 347 pDriver->PushNoteLoop(m_pNoteLoop.get()); |
| 348 m_bDoModalFlag = TRUE; | 348 m_bDoModalFlag = true; |
| 349 SetStates(FWL_WGTSTATE_Invisible, FALSE); | 349 SetStates(FWL_WGTSTATE_Invisible, false); |
| 350 pDriver->Run(); | 350 pDriver->Run(); |
| 351 #if (_FX_OS_ == _FX_MACOSX_) | 351 #if (_FX_OS_ == _FX_MACOSX_) |
| 352 #else | 352 #else |
| 353 pDriver->PopNoteLoop(); | 353 pDriver->PopNoteLoop(); |
| 354 #endif | 354 #endif |
| 355 m_pNoteLoop.reset(); | 355 m_pNoteLoop.reset(); |
| 356 return nullptr; | 356 return nullptr; |
| 357 } | 357 } |
| 358 | 358 |
| 359 IFWL_Widget* IFWL_Form::DoModal(uint32_t& dwCommandID) { | 359 IFWL_Widget* IFWL_Form::DoModal(uint32_t& dwCommandID) { |
| 360 return DoModal(); | 360 return DoModal(); |
| 361 } | 361 } |
| 362 | 362 |
| 363 FWL_Error IFWL_Form::EndDoModal() { | 363 FWL_Error IFWL_Form::EndDoModal() { |
| 364 if (!m_pNoteLoop) | 364 if (!m_pNoteLoop) |
| 365 return FWL_Error::Indefinite; | 365 return FWL_Error::Indefinite; |
| 366 m_bDoModalFlag = FALSE; | 366 m_bDoModalFlag = false; |
| 367 #if (_FX_OS_ == _FX_MACOSX_) | 367 #if (_FX_OS_ == _FX_MACOSX_) |
| 368 m_pNoteLoop->EndModalLoop(); | 368 m_pNoteLoop->EndModalLoop(); |
| 369 const IFWL_App* pApp = GetOwnerApp(); | 369 const IFWL_App* pApp = GetOwnerApp(); |
| 370 if (!pApp) | 370 if (!pApp) |
| 371 return FWL_Error::Indefinite; | 371 return FWL_Error::Indefinite; |
| 372 | 372 |
| 373 CFWL_NoteDriver* pDriver = | 373 CFWL_NoteDriver* pDriver = |
| 374 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 374 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
| 375 if (!pDriver) | 375 if (!pDriver) |
| 376 return FWL_Error::Indefinite; | 376 return FWL_Error::Indefinite; |
| 377 | 377 |
| 378 pDriver->PopNoteLoop(); | 378 pDriver->PopNoteLoop(); |
| 379 SetStates(FWL_WGTSTATE_Invisible, TRUE); | 379 SetStates(FWL_WGTSTATE_Invisible, true); |
| 380 return FWL_Error::Succeeded; | 380 return FWL_Error::Succeeded; |
| 381 #else | 381 #else |
| 382 SetStates(FWL_WGTSTATE_Invisible, TRUE); | 382 SetStates(FWL_WGTSTATE_Invisible, true); |
| 383 return m_pNoteLoop->EndModalLoop(); | 383 return m_pNoteLoop->EndModalLoop(); |
| 384 #endif | 384 #endif |
| 385 } | 385 } |
| 386 | 386 |
| 387 FWL_Error IFWL_Form::SetBorderRegion(CFX_Path* pPath) { | 387 FWL_Error IFWL_Form::SetBorderRegion(CFX_Path* pPath) { |
| 388 return FWL_Error::Succeeded; | 388 return FWL_Error::Succeeded; |
| 389 } | 389 } |
| 390 void IFWL_Form::DrawBackground(CFX_Graphics* pGraphics, | 390 void IFWL_Form::DrawBackground(CFX_Graphics* pGraphics, |
| 391 IFWL_ThemeProvider* pTheme) { | 391 IFWL_ThemeProvider* pTheme) { |
| 392 CFWL_ThemeBackground param; | 392 CFWL_ThemeBackground param; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 } | 554 } |
| 555 void IFWL_Form::DrawIconImage(CFX_Graphics* pGs, | 555 void IFWL_Form::DrawIconImage(CFX_Graphics* pGs, |
| 556 IFWL_ThemeProvider* pTheme, | 556 IFWL_ThemeProvider* pTheme, |
| 557 const CFX_Matrix* pMatrix) { | 557 const CFX_Matrix* pMatrix) { |
| 558 IFWL_FormDP* pData = | 558 IFWL_FormDP* pData = |
| 559 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); | 559 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); |
| 560 CFWL_ThemeBackground param; | 560 CFWL_ThemeBackground param; |
| 561 param.m_pWidget = this; | 561 param.m_pWidget = this; |
| 562 param.m_iPart = CFWL_Part::Icon; | 562 param.m_iPart = CFWL_Part::Icon; |
| 563 param.m_pGraphics = pGs; | 563 param.m_pGraphics = pGs; |
| 564 param.m_pImage = pData->GetIcon(this, FALSE); | 564 param.m_pImage = pData->GetIcon(this, false); |
| 565 param.m_rtPart = m_rtIcon; | 565 param.m_rtPart = m_rtIcon; |
| 566 if (pMatrix) { | 566 if (pMatrix) { |
| 567 param.m_matrix.Concat(*pMatrix); | 567 param.m_matrix.Concat(*pMatrix); |
| 568 } | 568 } |
| 569 pTheme->DrawBackground(¶m); | 569 pTheme->DrawBackground(¶m); |
| 570 } | 570 } |
| 571 void IFWL_Form::GetEdgeRect(CFX_RectF& rtEdge) { | 571 void IFWL_Form::GetEdgeRect(CFX_RectF& rtEdge) { |
| 572 rtEdge = m_rtRelative; | 572 rtEdge = m_rtRelative; |
| 573 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) { | 573 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) { |
| 574 FX_FLOAT fCX = GetBorderSize(); | 574 FX_FLOAT fCX = GetBorderSize(); |
| 575 FX_FLOAT fCY = GetBorderSize(FALSE); | 575 FX_FLOAT fCY = GetBorderSize(false); |
| 576 rtEdge.Deflate(fCX, m_rtCaption.Height(), fCX, fCY); | 576 rtEdge.Deflate(fCX, m_rtCaption.Height(), fCX, fCY); |
| 577 } | 577 } |
| 578 } | 578 } |
| 579 void IFWL_Form::SetWorkAreaRect() { | 579 void IFWL_Form::SetWorkAreaRect() { |
| 580 m_rtRestore = m_pProperties->m_rtWidget; | 580 m_rtRestore = m_pProperties->m_rtWidget; |
| 581 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); | 581 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); |
| 582 if (!pWidgetMgr) | 582 if (!pWidgetMgr) |
| 583 return; | 583 return; |
| 584 m_bSetMaximize = TRUE; | 584 m_bSetMaximize = true; |
| 585 Repaint(&m_rtRelative); | 585 Repaint(&m_rtRelative); |
| 586 } | 586 } |
| 587 void IFWL_Form::SetCursor(FX_FLOAT fx, FX_FLOAT fy) {} | 587 void IFWL_Form::SetCursor(FX_FLOAT fx, FX_FLOAT fy) {} |
| 588 void IFWL_Form::Layout() { | 588 void IFWL_Form::Layout() { |
| 589 GetRelativeRect(m_rtRelative); | 589 GetRelativeRect(m_rtRelative); |
| 590 #ifndef FWL_UseMacSystemBorder | 590 #ifndef FWL_UseMacSystemBorder |
| 591 ReSetSysBtn(); | 591 ReSetSysBtn(); |
| 592 #endif | 592 #endif |
| 593 } | 593 } |
| 594 void IFWL_Form::ReSetSysBtn() { | 594 void IFWL_Form::ReSetSysBtn() { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 m_pMinBox->m_rtBtn.Set( | 644 m_pMinBox->m_rtBtn.Set( |
| 645 m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize, | 645 m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize, |
| 646 kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize); | 646 kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize); |
| 647 } | 647 } |
| 648 } | 648 } |
| 649 m_iSysBox++; | 649 m_iSysBox++; |
| 650 } | 650 } |
| 651 IFWL_FormDP* pData = | 651 IFWL_FormDP* pData = |
| 652 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); | 652 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); |
| 653 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon && | 653 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon && |
| 654 pData->GetIcon(this, FALSE)) { | 654 pData->GetIcon(this, false)) { |
| 655 if (!m_bCustomizeLayout) { | 655 if (!m_bCustomizeLayout) { |
| 656 m_rtIcon.Set(5, (m_rtCaption.height - m_fSmallIconSz) / 2, m_fSmallIconSz, | 656 m_rtIcon.Set(5, (m_rtCaption.height - m_fSmallIconSz) / 2, m_fSmallIconSz, |
| 657 m_fSmallIconSz); | 657 m_fSmallIconSz); |
| 658 } | 658 } |
| 659 } | 659 } |
| 660 } | 660 } |
| 661 void IFWL_Form::RegisterForm() { | 661 void IFWL_Form::RegisterForm() { |
| 662 const IFWL_App* pApp = GetOwnerApp(); | 662 const IFWL_App* pApp = GetOwnerApp(); |
| 663 if (!pApp) | 663 if (!pApp) |
| 664 return; | 664 return; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 675 if (!pApp) | 675 if (!pApp) |
| 676 return; | 676 return; |
| 677 | 677 |
| 678 CFWL_NoteDriver* pDriver = | 678 CFWL_NoteDriver* pDriver = |
| 679 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 679 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
| 680 if (!pDriver) | 680 if (!pDriver) |
| 681 return; | 681 return; |
| 682 | 682 |
| 683 pDriver->UnRegisterForm(this); | 683 pDriver->UnRegisterForm(this); |
| 684 } | 684 } |
| 685 FX_BOOL IFWL_Form::IsDoModal() { | 685 bool IFWL_Form::IsDoModal() { |
| 686 return m_bDoModalFlag; | 686 return m_bDoModalFlag; |
| 687 } | 687 } |
| 688 void IFWL_Form::SetThemeData() { | 688 void IFWL_Form::SetThemeData() { |
| 689 m_fSmallIconSz = | 689 m_fSmallIconSz = |
| 690 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::SmallIcon)); | 690 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::SmallIcon)); |
| 691 m_fBigIconSz = | 691 m_fBigIconSz = |
| 692 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::BigIcon)); | 692 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::BigIcon)); |
| 693 } | 693 } |
| 694 FX_BOOL IFWL_Form::HasIcon() { | 694 bool IFWL_Form::HasIcon() { |
| 695 IFWL_FormDP* pData = | 695 IFWL_FormDP* pData = |
| 696 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); | 696 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); |
| 697 return !!pData->GetIcon(this, FALSE); | 697 return !!pData->GetIcon(this, false); |
| 698 } | 698 } |
| 699 void IFWL_Form::UpdateIcon() { | 699 void IFWL_Form::UpdateIcon() { |
| 700 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); | 700 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); |
| 701 if (!pWidgetMgr) | 701 if (!pWidgetMgr) |
| 702 return; | 702 return; |
| 703 IFWL_FormDP* pData = | 703 IFWL_FormDP* pData = |
| 704 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); | 704 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); |
| 705 CFX_DIBitmap* pBigIcon = pData->GetIcon(this, TRUE); | 705 CFX_DIBitmap* pBigIcon = pData->GetIcon(this, true); |
| 706 CFX_DIBitmap* pSmallIcon = pData->GetIcon(this, FALSE); | 706 CFX_DIBitmap* pSmallIcon = pData->GetIcon(this, false); |
| 707 if (pBigIcon) | 707 if (pBigIcon) |
| 708 m_pBigIcon = pBigIcon; | 708 m_pBigIcon = pBigIcon; |
| 709 if (pSmallIcon) | 709 if (pSmallIcon) |
| 710 m_pSmallIcon = pSmallIcon; | 710 m_pSmallIcon = pSmallIcon; |
| 711 } | 711 } |
| 712 void IFWL_Form::UpdateCaption() { | 712 void IFWL_Form::UpdateCaption() { |
| 713 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); | 713 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); |
| 714 if (!pWidgetMgr) | 714 if (!pWidgetMgr) |
| 715 return; | 715 return; |
| 716 IFWL_DataProvider* pData = m_pProperties->m_pDataProvider; | 716 IFWL_DataProvider* pData = m_pProperties->m_pDataProvider; |
| 717 if (!pData) | 717 if (!pData) |
| 718 return; | 718 return; |
| 719 CFX_WideString text; | 719 CFX_WideString text; |
| 720 pData->GetCaption(this, text); | 720 pData->GetCaption(this, text); |
| 721 } | 721 } |
| 722 void IFWL_Form::DoWidthLimit(FX_FLOAT& fLeft, | 722 void IFWL_Form::DoWidthLimit(FX_FLOAT& fLeft, |
| 723 FX_FLOAT& fWidth, | 723 FX_FLOAT& fWidth, |
| 724 FX_FLOAT fCurX, | 724 FX_FLOAT fCurX, |
| 725 FX_FLOAT fSpace, | 725 FX_FLOAT fSpace, |
| 726 FX_FLOAT fLimitMin, | 726 FX_FLOAT fLimitMin, |
| 727 FX_FLOAT fLimitMax, | 727 FX_FLOAT fLimitMax, |
| 728 FX_BOOL bLeft) { | 728 bool bLeft) { |
| 729 FX_FLOAT fx = fCurX; | 729 FX_FLOAT fx = fCurX; |
| 730 FX_FLOAT fy = 0; | 730 FX_FLOAT fy = 0; |
| 731 TransformTo(nullptr, fx, fy); | 731 TransformTo(nullptr, fx, fy); |
| 732 FX_FLOAT fTemp = | 732 FX_FLOAT fTemp = |
| 733 bLeft ? (fWidth - fx + fLeft + fSpace) : (fx - fLeft + fSpace); | 733 bLeft ? (fWidth - fx + fLeft + fSpace) : (fx - fLeft + fSpace); |
| 734 if (fTemp >= fLimitMin && fTemp <= fLimitMax) { | 734 if (fTemp >= fLimitMin && fTemp <= fLimitMax) { |
| 735 fWidth = fTemp; | 735 fWidth = fTemp; |
| 736 fLeft += bLeft ? (fx - fLeft - fSpace) : 0; | 736 fLeft += bLeft ? (fx - fLeft - fSpace) : 0; |
| 737 } else { | 737 } else { |
| 738 if (fTemp < fLimitMin && fWidth > fLimitMin) { | 738 if (fTemp < fLimitMin && fWidth > fLimitMin) { |
| 739 fLeft += bLeft ? (fWidth - fLimitMin) : 0; | 739 fLeft += bLeft ? (fWidth - fLimitMin) : 0; |
| 740 fWidth = fLimitMin; | 740 fWidth = fLimitMin; |
| 741 } else if (fTemp > fLimitMax && fWidth < fLimitMax) { | 741 } else if (fTemp > fLimitMax && fWidth < fLimitMax) { |
| 742 fLeft -= bLeft ? (fLimitMax - fWidth) : 0; | 742 fLeft -= bLeft ? (fLimitMax - fWidth) : 0; |
| 743 fWidth = fLimitMax; | 743 fWidth = fLimitMax; |
| 744 } | 744 } |
| 745 } | 745 } |
| 746 } | 746 } |
| 747 void IFWL_Form::DoHeightLimit(FX_FLOAT& fTop, | 747 void IFWL_Form::DoHeightLimit(FX_FLOAT& fTop, |
| 748 FX_FLOAT& fHeight, | 748 FX_FLOAT& fHeight, |
| 749 FX_FLOAT fCurY, | 749 FX_FLOAT fCurY, |
| 750 FX_FLOAT fSpace, | 750 FX_FLOAT fSpace, |
| 751 FX_FLOAT fLimitMin, | 751 FX_FLOAT fLimitMin, |
| 752 FX_FLOAT fLimitMax, | 752 FX_FLOAT fLimitMax, |
| 753 FX_BOOL bTop) { | 753 bool bTop) { |
| 754 FX_FLOAT fx = 0; | 754 FX_FLOAT fx = 0; |
| 755 FX_FLOAT fy = fCurY; | 755 FX_FLOAT fy = fCurY; |
| 756 TransformTo(nullptr, fx, fy); | 756 TransformTo(nullptr, fx, fy); |
| 757 FX_FLOAT fTemp = bTop ? (fHeight - fy + fTop + fSpace) : (fy - fTop + fSpace); | 757 FX_FLOAT fTemp = bTop ? (fHeight - fy + fTop + fSpace) : (fy - fTop + fSpace); |
| 758 if (fTemp >= fLimitMin && fTemp <= fLimitMax) { | 758 if (fTemp >= fLimitMin && fTemp <= fLimitMax) { |
| 759 fHeight = fTemp; | 759 fHeight = fTemp; |
| 760 fTop += bTop ? (fy - fTop - fSpace) : 0; | 760 fTop += bTop ? (fy - fTop - fSpace) : 0; |
| 761 } else { | 761 } else { |
| 762 if (fTemp < fLimitMin && fHeight > fLimitMin) { | 762 if (fTemp < fLimitMin && fHeight > fLimitMin) { |
| 763 fTop += bTop ? (fHeight - fLimitMin) : 0; | 763 fTop += bTop ? (fHeight - fLimitMin) : 0; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 } | 854 } |
| 855 case CFWL_MessageType::Size: { | 855 case CFWL_MessageType::Size: { |
| 856 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); | 856 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); |
| 857 if (!pWidgetMgr) | 857 if (!pWidgetMgr) |
| 858 return; | 858 return; |
| 859 | 859 |
| 860 pWidgetMgr->AddRedrawCounts(this); | 860 pWidgetMgr->AddRedrawCounts(this); |
| 861 if (!m_bSetMaximize) | 861 if (!m_bSetMaximize) |
| 862 break; | 862 break; |
| 863 | 863 |
| 864 m_bSetMaximize = FALSE; | 864 m_bSetMaximize = false; |
| 865 CFWL_MsgSize* pMsg = static_cast<CFWL_MsgSize*>(pMessage); | 865 CFWL_MsgSize* pMsg = static_cast<CFWL_MsgSize*>(pMessage); |
| 866 m_pProperties->m_rtWidget.left = 0; | 866 m_pProperties->m_rtWidget.left = 0; |
| 867 m_pProperties->m_rtWidget.top = 0; | 867 m_pProperties->m_rtWidget.top = 0; |
| 868 m_pProperties->m_rtWidget.width = (FX_FLOAT)pMsg->m_iWidth; | 868 m_pProperties->m_rtWidget.width = (FX_FLOAT)pMsg->m_iWidth; |
| 869 m_pProperties->m_rtWidget.height = (FX_FLOAT)pMsg->m_iHeight; | 869 m_pProperties->m_rtWidget.height = (FX_FLOAT)pMsg->m_iHeight; |
| 870 Update(); | 870 Update(); |
| 871 break; | 871 break; |
| 872 } | 872 } |
| 873 case CFWL_MessageType::WindowMove: | 873 case CFWL_MessageType::WindowMove: |
| 874 OnWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage)); | 874 OnWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage)); |
| 875 break; | 875 break; |
| 876 case CFWL_MessageType::Close: | 876 case CFWL_MessageType::Close: |
| 877 OnClose(static_cast<CFWL_MsgClose*>(pMessage)); | 877 OnClose(static_cast<CFWL_MsgClose*>(pMessage)); |
| 878 break; | 878 break; |
| 879 default: | 879 default: |
| 880 break; | 880 break; |
| 881 } | 881 } |
| 882 } | 882 } |
| 883 #endif // FWL_UseMacSystemBorder | 883 #endif // FWL_UseMacSystemBorder |
| 884 | 884 |
| 885 void IFWL_Form::OnDrawWidget(CFX_Graphics* pGraphics, | 885 void IFWL_Form::OnDrawWidget(CFX_Graphics* pGraphics, |
| 886 const CFX_Matrix* pMatrix) { | 886 const CFX_Matrix* pMatrix) { |
| 887 DrawWidget(pGraphics, pMatrix); | 887 DrawWidget(pGraphics, pMatrix); |
| 888 } | 888 } |
| 889 | 889 |
| 890 void IFWL_Form::OnLButtonDown(CFWL_MsgMouse* pMsg) { | 890 void IFWL_Form::OnLButtonDown(CFWL_MsgMouse* pMsg) { |
| 891 SetGrab(TRUE); | 891 SetGrab(true); |
| 892 m_bLButtonDown = TRUE; | 892 m_bLButtonDown = true; |
| 893 m_eResizeType = FORM_RESIZETYPE_None; | 893 m_eResizeType = FORM_RESIZETYPE_None; |
| 894 CFWL_SysBtn* pPressBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); | 894 CFWL_SysBtn* pPressBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); |
| 895 m_iCaptureBtn = GetSysBtnIndex(pPressBtn); | 895 m_iCaptureBtn = GetSysBtnIndex(pPressBtn); |
| 896 CFX_RectF rtCap; | 896 CFX_RectF rtCap; |
| 897 rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder, | 897 rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder, |
| 898 m_rtCaption.width - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder, | 898 m_rtCaption.width - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder, |
| 899 m_rtCaption.height - m_fCXBorder); | 899 m_rtCaption.height - m_fCXBorder); |
| 900 | 900 |
| 901 if (pPressBtn) { | 901 if (pPressBtn) { |
| 902 pPressBtn->SetPressed(); | 902 pPressBtn->SetPressed(); |
| 903 Repaint(&pPressBtn->m_rtBtn); | 903 Repaint(&pPressBtn->m_rtBtn); |
| 904 } else if (rtCap.Contains(pMsg->m_fx, pMsg->m_fy)) { | 904 } else if (rtCap.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| 905 m_eResizeType = FORM_RESIZETYPE_Cap; | 905 m_eResizeType = FORM_RESIZETYPE_Cap; |
| 906 } else if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && | 906 } else if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && |
| 907 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && | 907 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && |
| 908 !m_bMaximized) { | 908 !m_bMaximized) { |
| 909 SetCursor(pMsg->m_fx, pMsg->m_fy); | 909 SetCursor(pMsg->m_fx, pMsg->m_fy); |
| 910 } | 910 } |
| 911 m_InfoStart.m_ptStart = CFX_PointF(pMsg->m_fx, pMsg->m_fy); | 911 m_InfoStart.m_ptStart = CFX_PointF(pMsg->m_fx, pMsg->m_fy); |
| 912 m_InfoStart.m_szStart = CFX_SizeF(m_pProperties->m_rtWidget.width, | 912 m_InfoStart.m_szStart = CFX_SizeF(m_pProperties->m_rtWidget.width, |
| 913 m_pProperties->m_rtWidget.height); | 913 m_pProperties->m_rtWidget.height); |
| 914 } | 914 } |
| 915 | 915 |
| 916 void IFWL_Form::OnLButtonUp(CFWL_MsgMouse* pMsg) { | 916 void IFWL_Form::OnLButtonUp(CFWL_MsgMouse* pMsg) { |
| 917 SetGrab(FALSE); | 917 SetGrab(false); |
| 918 m_bLButtonDown = FALSE; | 918 m_bLButtonDown = false; |
| 919 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); | 919 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); |
| 920 CFWL_SysBtn* pPressedBtn = GetSysBtnByIndex(m_iCaptureBtn); | 920 CFWL_SysBtn* pPressedBtn = GetSysBtnByIndex(m_iCaptureBtn); |
| 921 if (!pPressedBtn || pPointBtn != pPressedBtn) | 921 if (!pPressedBtn || pPointBtn != pPressedBtn) |
| 922 return; | 922 return; |
| 923 if (pPressedBtn == GetSysBtnByState(FWL_SYSBUTTONSTATE_Pressed)) | 923 if (pPressedBtn == GetSysBtnByState(FWL_SYSBUTTONSTATE_Pressed)) |
| 924 pPressedBtn->SetNormal(); | 924 pPressedBtn->SetNormal(); |
| 925 if (pPressedBtn == m_pMaxBox) { | 925 if (pPressedBtn == m_pMaxBox) { |
| 926 if (m_bMaximized) { | 926 if (m_bMaximized) { |
| 927 SetWidgetRect(m_rtRestore); | 927 SetWidgetRect(m_rtRestore); |
| 928 Update(); | 928 Update(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 rtInvalidate.Union(m_pMaxBox->m_rtBtn); | 967 rtInvalidate.Union(m_pMaxBox->m_rtBtn); |
| 968 } | 968 } |
| 969 if (m_pMinBox) { | 969 if (m_pMinBox) { |
| 970 if (rtInvalidate.IsEmpty()) | 970 if (rtInvalidate.IsEmpty()) |
| 971 rtInvalidate = m_pMinBox->m_rtBtn; | 971 rtInvalidate = m_pMinBox->m_rtBtn; |
| 972 else | 972 else |
| 973 rtInvalidate.Union(m_pMinBox->m_rtBtn); | 973 rtInvalidate.Union(m_pMinBox->m_rtBtn); |
| 974 } | 974 } |
| 975 if (!rtInvalidate.IsEmpty() && | 975 if (!rtInvalidate.IsEmpty() && |
| 976 rtInvalidate.Contains(pMsg->m_fx, pMsg->m_fy)) { | 976 rtInvalidate.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| 977 m_bMouseIn = TRUE; | 977 m_bMouseIn = true; |
| 978 } | 978 } |
| 979 } | 979 } |
| 980 #else | 980 #else |
| 981 { | 981 { |
| 982 if (pOldHover && pPointBtn != pOldHover) { | 982 if (pOldHover && pPointBtn != pOldHover) { |
| 983 pOldHover->SetNormal(); | 983 pOldHover->SetNormal(); |
| 984 rtInvalidate = pOldHover->m_rtBtn; | 984 rtInvalidate = pOldHover->m_rtBtn; |
| 985 } | 985 } |
| 986 if (pPointBtn && pPointBtn != pOldHover) { | 986 if (pPointBtn && pPointBtn != pOldHover) { |
| 987 pPointBtn->SetHover(); | 987 pPointBtn->SetHover(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 void CFWL_SysBtn::SetPressed() { | 1050 void CFWL_SysBtn::SetPressed() { |
| 1051 SetNormal(); | 1051 SetNormal(); |
| 1052 m_dwState |= FWL_SYSBUTTONSTATE_Pressed; | 1052 m_dwState |= FWL_SYSBUTTONSTATE_Pressed; |
| 1053 } | 1053 } |
| 1054 | 1054 |
| 1055 void CFWL_SysBtn::SetHover() { | 1055 void CFWL_SysBtn::SetHover() { |
| 1056 SetNormal(); | 1056 SetNormal(); |
| 1057 m_dwState |= FWL_SYSBUTTONSTATE_Hover; | 1057 m_dwState |= FWL_SYSBUTTONSTATE_Hover; |
| 1058 } | 1058 } |
| 1059 | 1059 |
| 1060 void CFWL_SysBtn::SetDisabled(FX_BOOL bDisabled) { | 1060 void CFWL_SysBtn::SetDisabled(bool bDisabled) { |
| 1061 bDisabled ? m_dwState |= FWL_SYSBUTTONSTATE_Disabled | 1061 bDisabled ? m_dwState |= FWL_SYSBUTTONSTATE_Disabled |
| 1062 : m_dwState &= ~FWL_SYSBUTTONSTATE_Disabled; | 1062 : m_dwState &= ~FWL_SYSBUTTONSTATE_Disabled; |
| 1063 } | 1063 } |
| 1064 | 1064 |
| 1065 uint32_t CFWL_SysBtn::GetPartState() const { | 1065 uint32_t CFWL_SysBtn::GetPartState() const { |
| 1066 if (IsDisabled()) | 1066 if (IsDisabled()) |
| 1067 return CFWL_PartState_Disabled; | 1067 return CFWL_PartState_Disabled; |
| 1068 if (m_dwState & FWL_SYSBUTTONSTATE_Pressed) | 1068 if (m_dwState & FWL_SYSBUTTONSTATE_Pressed) |
| 1069 return CFWL_PartState_Pressed; | 1069 return CFWL_PartState_Pressed; |
| 1070 if (m_dwState & FWL_SYSBUTTONSTATE_Hover) | 1070 if (m_dwState & FWL_SYSBUTTONSTATE_Hover) |
| 1071 return CFWL_PartState_Hovered; | 1071 return CFWL_PartState_Hovered; |
| 1072 return CFWL_PartState_Normal; | 1072 return CFWL_PartState_Normal; |
| 1073 } | 1073 } |
| OLD | NEW |