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 "../../../foxitlib.h" | 7 #include "../../../foxitlib.h" |
8 #include "../../src/core/include/fwl_threadimp.h" | 8 #include "../../src/core/include/fwl_threadimp.h" |
9 #include "../../src/core/include/fwl_appimp.h" | 9 #include "../../src/core/include/fwl_appimp.h" |
10 #include "../core/include/fwl_targetimp.h" | 10 #include "../core/include/fwl_targetimp.h" |
11 #include "../core/include/fwl_noteimp.h" | 11 #include "../core/include/fwl_noteimp.h" |
12 #include "../core/include/fwl_widgetimp.h" | 12 #include "../core/include/fwl_widgetimp.h" |
13 #include "../core/include/fwl_panelimp.h" | 13 #include "../core/include/fwl_panelimp.h" |
14 #include "../core/include/fwl_formimp.h" | 14 #include "../core/include/fwl_formimp.h" |
15 #include "../core/include/fwl_widgetmgrimp.h" | 15 #include "../core/include/fwl_widgetmgrimp.h" |
16 #include "include/fwl_scrollbarimp.h" | 16 #include "include/fwl_scrollbarimp.h" |
17 #include "include/fwl_editimp.h" | 17 #include "include/fwl_editimp.h" |
18 #include "include/fwl_listboximp.h" | 18 #include "include/fwl_listboximp.h" |
19 #include "include/fwl_formproxyimp.h" | 19 #include "include/fwl_formproxyimp.h" |
20 #include "include/fwl_comboboximp.h" | 20 #include "include/fwl_comboboximp.h" |
21 IFWL_ComboBox* IFWL_ComboBox::Create() { | |
22 return new IFWL_ComboBox; | |
23 } | |
24 IFWL_ComboBox::IFWL_ComboBox() { | 21 IFWL_ComboBox::IFWL_ComboBox() { |
25 } | 22 } |
26 FWL_ERR IFWL_ComboBox::Initialize(const CFWL_WidgetImpProperties& properties, | 23 FWL_ERR IFWL_ComboBox::Initialize(const CFWL_WidgetImpProperties& properties, |
27 IFWL_Widget* pOuter) { | 24 IFWL_Widget* pOuter) { |
28 CFWL_ComboBoxImp* pComboBoxImpl = new CFWL_ComboBoxImp(properties, pOuter); | 25 CFWL_ComboBoxImp* pComboBoxImpl = new CFWL_ComboBoxImp(properties, pOuter); |
29 SetImpl(pComboBoxImpl); | 26 SetImpl(pComboBoxImpl); |
30 pComboBoxImpl->SetInterface(this); | 27 pComboBoxImpl->SetInterface(this); |
31 return pComboBoxImpl->Initialize(); | 28 return pComboBoxImpl->Initialize(); |
32 } | 29 } |
33 int32_t IFWL_ComboBox::GetCurSel() { | 30 int32_t IFWL_ComboBox::GetCurSel() { |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 } | 332 } |
336 return CFWL_ListBoxImpDelegate::OnProcessMessage(pMessage); | 333 return CFWL_ListBoxImpDelegate::OnProcessMessage(pMessage); |
337 } | 334 } |
338 void CFWL_ComboListImpDelegate::OnDropListFocusChanged(CFWL_Message* pMsg, | 335 void CFWL_ComboListImpDelegate::OnDropListFocusChanged(CFWL_Message* pMsg, |
339 FX_BOOL bSet) { | 336 FX_BOOL bSet) { |
340 if (!bSet) { | 337 if (!bSet) { |
341 CFWL_MsgKillFocus* pKill = static_cast<CFWL_MsgKillFocus*>(pMsg); | 338 CFWL_MsgKillFocus* pKill = static_cast<CFWL_MsgKillFocus*>(pMsg); |
342 CFWL_ComboBoxImp* pOuter = | 339 CFWL_ComboBoxImp* pOuter = |
343 static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl()); | 340 static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl()); |
344 if (pKill->m_pSetFocus == m_pOwner->m_pOuter || | 341 if (pKill->m_pSetFocus == m_pOwner->m_pOuter || |
345 pKill->m_pSetFocus == pOuter->m_pEdit) { | 342 pKill->m_pSetFocus == pOuter->m_pEdit.get()) { |
346 pOuter->ShowDropList(FALSE); | 343 pOuter->ShowDropList(FALSE); |
347 } | 344 } |
348 } | 345 } |
349 } | 346 } |
350 int32_t CFWL_ComboListImpDelegate::OnDropListMouseMove(CFWL_MsgMouse* pMsg) { | 347 int32_t CFWL_ComboListImpDelegate::OnDropListMouseMove(CFWL_MsgMouse* pMsg) { |
351 if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { | 348 if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { |
352 if (m_pOwner->m_bNotifyOwner) { | 349 if (m_pOwner->m_bNotifyOwner) { |
353 m_pOwner->m_bNotifyOwner = FALSE; | 350 m_pOwner->m_bNotifyOwner = FALSE; |
354 } | 351 } |
355 if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) { | 352 if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width, | 462 rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width, |
466 m_pOwner->m_pProperties->m_rtWidget.height); | 463 m_pOwner->m_pProperties->m_rtWidget.height); |
467 m_pOwner->Repaint(&rtInvalidate); | 464 m_pOwner->Repaint(&rtInvalidate); |
468 break; | 465 break; |
469 } | 466 } |
470 default: {} | 467 default: {} |
471 } | 468 } |
472 } | 469 } |
473 CFWL_ComboBoxImp::CFWL_ComboBoxImp(IFWL_Widget* pOuter) | 470 CFWL_ComboBoxImp::CFWL_ComboBoxImp(IFWL_Widget* pOuter) |
474 : CFWL_WidgetImp(pOuter), | 471 : CFWL_WidgetImp(pOuter), |
475 m_pEdit(NULL), | |
476 m_pListBox(NULL), | |
477 m_pForm(NULL), | 472 m_pForm(NULL), |
478 m_bLButtonDown(FALSE), | 473 m_bLButtonDown(FALSE), |
479 m_iCurSel(-1), | 474 m_iCurSel(-1), |
480 m_iBtnState(FWL_PARTSTATE_CMB_Normal), | 475 m_iBtnState(FWL_PARTSTATE_CMB_Normal), |
481 m_fComboFormHandler(0), | 476 m_fComboFormHandler(0), |
482 m_bNeedShowList(FALSE) { | 477 m_bNeedShowList(FALSE) { |
483 m_rtClient.Reset(); | 478 m_rtClient.Reset(); |
484 m_rtBtn.Reset(); | 479 m_rtBtn.Reset(); |
485 m_rtHandler.Reset(); | 480 m_rtHandler.Reset(); |
486 } | 481 } |
487 CFWL_ComboBoxImp::CFWL_ComboBoxImp(const CFWL_WidgetImpProperties& properties, | 482 CFWL_ComboBoxImp::CFWL_ComboBoxImp(const CFWL_WidgetImpProperties& properties, |
488 IFWL_Widget* pOuter) | 483 IFWL_Widget* pOuter) |
489 : CFWL_WidgetImp(properties, pOuter), | 484 : CFWL_WidgetImp(properties, pOuter), |
490 m_pEdit(NULL), | |
491 m_pListBox(NULL), | |
492 m_pForm(NULL), | 485 m_pForm(NULL), |
493 m_bLButtonDown(FALSE), | 486 m_bLButtonDown(FALSE), |
494 m_iCurSel(-1), | 487 m_iCurSel(-1), |
495 m_iBtnState(FWL_PARTSTATE_CMB_Normal), | 488 m_iBtnState(FWL_PARTSTATE_CMB_Normal), |
496 m_fComboFormHandler(0), | 489 m_fComboFormHandler(0), |
497 m_bNeedShowList(FALSE) { | 490 m_bNeedShowList(FALSE) { |
498 m_rtClient.Reset(); | 491 m_rtClient.Reset(); |
499 m_rtBtn.Reset(); | 492 m_rtBtn.Reset(); |
500 m_rtHandler.Reset(); | 493 m_rtHandler.Reset(); |
501 } | 494 } |
502 CFWL_ComboBoxImp::~CFWL_ComboBoxImp() { | 495 CFWL_ComboBoxImp::~CFWL_ComboBoxImp() { |
503 if (m_pEdit) { | |
504 m_pEdit->Release(); | |
505 m_pEdit = NULL; | |
506 } | |
507 if (m_pListBox) { | |
508 m_pListBox->Release(); | |
509 m_pListBox = NULL; | |
510 } | |
511 } | 496 } |
512 FWL_ERR CFWL_ComboBoxImp::GetClassName(CFX_WideString& wsClass) const { | 497 FWL_ERR CFWL_ComboBoxImp::GetClassName(CFX_WideString& wsClass) const { |
513 wsClass = FWL_CLASS_ComboBox; | 498 wsClass = FWL_CLASS_ComboBox; |
514 return FWL_ERR_Succeeded; | 499 return FWL_ERR_Succeeded; |
515 } | 500 } |
516 FX_DWORD CFWL_ComboBoxImp::GetClassID() const { | 501 FX_DWORD CFWL_ComboBoxImp::GetClassID() const { |
517 return FWL_CLASSHASH_ComboBox; | 502 return FWL_CLASSHASH_ComboBox; |
518 } | 503 } |
519 FWL_ERR CFWL_ComboBoxImp::Initialize() { | 504 FWL_ERR CFWL_ComboBoxImp::Initialize() { |
520 if (m_pWidgetMgr->IsFormDisabled()) { | 505 if (m_pWidgetMgr->IsFormDisabled()) { |
521 return DisForm_Initialize(); | 506 return DisForm_Initialize(); |
522 } | 507 } |
523 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) | 508 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) |
524 return FWL_WGTSTATE_Invisible; // Probably a bug; not a FWL_ERR_ value. | 509 return FWL_WGTSTATE_Invisible; // Probably a bug; not a FWL_ERR_ value. |
525 m_pDelegate = new CFWL_ComboBoxImpDelegate(this); | 510 m_pDelegate = new CFWL_ComboBoxImpDelegate(this); |
526 CFWL_WidgetImpProperties prop; | 511 CFWL_WidgetImpProperties prop; |
527 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; | 512 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; |
528 prop.m_dwStyles |= FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; | 513 prop.m_dwStyles |= FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; |
529 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemIconText) { | 514 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemIconText) { |
530 prop.m_dwStyleExes |= FWL_STYLEEXT_LTB_Icon; | 515 prop.m_dwStyleExes |= FWL_STYLEEXT_LTB_Icon; |
531 } | 516 } |
532 prop.m_pDataProvider = m_pProperties->m_pDataProvider; | 517 prop.m_pDataProvider = m_pProperties->m_pDataProvider; |
533 CFWL_ComboListImp* pList = new CFWL_ComboListImp(prop, m_pInterface); | 518 CFWL_ComboListImp* pList = new CFWL_ComboListImp(prop, m_pInterface); |
534 m_pListBox = IFWL_ListBox::Create(); | 519 m_pListBox.reset(new IFWL_ListBox); |
535 pList->SetInterface(m_pListBox); | 520 pList->SetInterface(m_pListBox.get()); |
536 m_pListBox->SetImpl(pList); | 521 m_pListBox->SetImpl(pList); |
537 pList->Initialize(); | 522 pList->Initialize(); |
538 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) && !m_pEdit) { | 523 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) && !m_pEdit) { |
539 CFWL_ComboEditImp* pEdit = new CFWL_ComboEditImp(m_pInterface); | 524 CFWL_ComboEditImp* pEdit = new CFWL_ComboEditImp(m_pInterface); |
540 m_pEdit = IFWL_Edit::Create(); | 525 m_pEdit.reset(new IFWL_Edit); |
541 pEdit->SetInterface(m_pEdit); | 526 pEdit->SetInterface(m_pEdit.get()); |
542 m_pEdit->SetImpl(pEdit); | 527 m_pEdit->SetImpl(pEdit); |
543 pEdit->Initialize(); | 528 pEdit->Initialize(); |
544 pEdit->SetOuter(m_pInterface); | 529 pEdit->SetOuter(m_pInterface); |
545 } | 530 } |
546 if (m_pEdit) { | 531 if (m_pEdit) { |
547 m_pEdit->SetParent(m_pInterface); | 532 m_pEdit->SetParent(m_pInterface); |
548 } | 533 } |
549 SetStates(m_pProperties->m_dwStates); | 534 SetStates(m_pProperties->m_dwStates); |
550 return FWL_ERR_Succeeded; | 535 return FWL_ERR_Succeeded; |
551 } | 536 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 } | 569 } |
585 FWL_ERR CFWL_ComboBoxImp::ModifyStylesEx(FX_DWORD dwStylesExAdded, | 570 FWL_ERR CFWL_ComboBoxImp::ModifyStylesEx(FX_DWORD dwStylesExAdded, |
586 FX_DWORD dwStylesExRemoved) { | 571 FX_DWORD dwStylesExRemoved) { |
587 if (m_pWidgetMgr->IsFormDisabled()) { | 572 if (m_pWidgetMgr->IsFormDisabled()) { |
588 return DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | 573 return DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
589 } | 574 } |
590 FX_BOOL bAddDropDown = dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown; | 575 FX_BOOL bAddDropDown = dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown; |
591 FX_BOOL bRemoveDropDown = dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown; | 576 FX_BOOL bRemoveDropDown = dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown; |
592 if (bAddDropDown && !m_pEdit) { | 577 if (bAddDropDown && !m_pEdit) { |
593 CFWL_ComboEditImp* pEdit = new CFWL_ComboEditImp(m_pInterface); | 578 CFWL_ComboEditImp* pEdit = new CFWL_ComboEditImp(m_pInterface); |
594 m_pEdit = IFWL_Edit::Create(); | 579 m_pEdit.reset(new IFWL_Edit); |
595 pEdit->SetInterface(m_pEdit); | 580 pEdit->SetInterface(m_pEdit.get()); |
596 m_pEdit->SetImpl(pEdit); | 581 m_pEdit->SetImpl(pEdit); |
597 pEdit->Initialize(); | 582 pEdit->Initialize(); |
598 pEdit->SetOuter(m_pInterface); | 583 pEdit->SetOuter(m_pInterface); |
599 m_pEdit->SetParent(m_pInterface); | 584 m_pEdit->SetParent(m_pInterface); |
600 } else if (bRemoveDropDown && m_pEdit) { | 585 } else if (bRemoveDropDown && m_pEdit) { |
601 m_pEdit->SetStates(FWL_WGTSTATE_Invisible, TRUE); | 586 m_pEdit->SetStates(FWL_WGTSTATE_Invisible, TRUE); |
602 } | 587 } |
603 return CFWL_WidgetImp::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | 588 return CFWL_WidgetImp::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
604 } | 589 } |
605 FWL_ERR CFWL_ComboBoxImp::Update() { | 590 FWL_ERR CFWL_ComboBoxImp::Update() { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 param.m_iPart = FWL_PART_CMB_Background; | 641 param.m_iPart = FWL_PART_CMB_Background; |
657 param.m_pGraphics = pGraphics; | 642 param.m_pGraphics = pGraphics; |
658 if (pMatrix) { | 643 if (pMatrix) { |
659 param.m_matrix.Concat(*pMatrix); | 644 param.m_matrix.Concat(*pMatrix); |
660 } | 645 } |
661 param.m_rtPart = rtTextBk; | 646 param.m_rtPart = rtTextBk; |
662 if (m_iCurSel >= 0) { | 647 if (m_iCurSel >= 0) { |
663 IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>( | 648 IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>( |
664 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) | 649 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) |
665 ->m_pProperties->m_pDataProvider); | 650 ->m_pProperties->m_pDataProvider); |
666 void* p = | 651 void* p = pData->GetItemData(m_pListBox.get(), |
667 pData->GetItemData(m_pListBox, pData->GetItem(m_pListBox, m_iCurSel)); | 652 pData->GetItem(m_pListBox.get(), m_iCurSel)); |
668 if (p != NULL) { | 653 if (p != NULL) { |
669 param.m_pData = p; | 654 param.m_pData = p; |
670 } | 655 } |
671 } | 656 } |
672 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { | 657 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { |
673 param.m_dwStates = FWL_PARTSTATE_CMB_Disabled; | 658 param.m_dwStates = FWL_PARTSTATE_CMB_Disabled; |
674 } else if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && | 659 } else if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && |
675 (m_iCurSel >= 0)) { | 660 (m_iCurSel >= 0)) { |
676 param.m_dwStates = FWL_PARTSTATE_CMB_Selected; | 661 param.m_dwStates = FWL_PARTSTATE_CMB_Selected; |
677 } else { | 662 } else { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 param.m_matrix.Concat(*pMatrix); | 699 param.m_matrix.Concat(*pMatrix); |
715 param.m_rtPart = m_rtBtn; | 700 param.m_rtPart = m_rtBtn; |
716 pTheme->DrawBackground(¶m); | 701 pTheme->DrawBackground(¶m); |
717 } | 702 } |
718 return FWL_ERR_Succeeded; | 703 return FWL_ERR_Succeeded; |
719 } | 704 } |
720 FWL_ERR CFWL_ComboBoxImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | 705 FWL_ERR CFWL_ComboBoxImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { |
721 if (!pThemeProvider) | 706 if (!pThemeProvider) |
722 return FWL_ERR_Indefinite; | 707 return FWL_ERR_Indefinite; |
723 m_pProperties->m_pThemeProvider = pThemeProvider; | 708 m_pProperties->m_pThemeProvider = pThemeProvider; |
724 if (m_pListBox && pThemeProvider->IsValidWidget(m_pListBox)) { | 709 if (m_pListBox && pThemeProvider->IsValidWidget(m_pListBox.get())) { |
725 m_pListBox->SetThemeProvider(pThemeProvider); | 710 m_pListBox->SetThemeProvider(pThemeProvider); |
726 } | 711 } |
727 if (m_pEdit && pThemeProvider->IsValidWidget(m_pEdit)) { | 712 if (m_pEdit && pThemeProvider->IsValidWidget(m_pEdit.get())) { |
728 m_pEdit->SetThemeProvider(pThemeProvider); | 713 m_pEdit->SetThemeProvider(pThemeProvider); |
729 } | 714 } |
730 return FWL_ERR_Succeeded; | 715 return FWL_ERR_Succeeded; |
731 } | 716 } |
732 int32_t CFWL_ComboBoxImp::GetCurSel() { | 717 int32_t CFWL_ComboBoxImp::GetCurSel() { |
733 return m_iCurSel; | 718 return m_iCurSel; |
734 } | 719 } |
735 FWL_ERR CFWL_ComboBoxImp::SetCurSel(int32_t iSel) { | 720 FWL_ERR CFWL_ComboBoxImp::SetCurSel(int32_t iSel) { |
736 int32_t iCount = | 721 int32_t iCount = |
737 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->CountItems(); | 722 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->CountItems(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 if (!m_pEdit) | 804 if (!m_pEdit) |
820 return FALSE; | 805 return FALSE; |
821 return m_pEdit->Redo(bsRecord); | 806 return m_pEdit->Redo(bsRecord); |
822 } | 807 } |
823 FX_BOOL CFWL_ComboBoxImp::EditUndo(const CFX_ByteStringC& bsRecord) { | 808 FX_BOOL CFWL_ComboBoxImp::EditUndo(const CFX_ByteStringC& bsRecord) { |
824 if (!m_pEdit) | 809 if (!m_pEdit) |
825 return FALSE; | 810 return FALSE; |
826 return m_pEdit->Undo(bsRecord); | 811 return m_pEdit->Undo(bsRecord); |
827 } | 812 } |
828 IFWL_ListBox* CFWL_ComboBoxImp::GetListBoxt() { | 813 IFWL_ListBox* CFWL_ComboBoxImp::GetListBoxt() { |
829 if (!m_pListBox) | 814 return m_pListBox.get(); |
830 return FALSE; | |
831 return m_pListBox; | |
832 } | 815 } |
833 FX_BOOL CFWL_ComboBoxImp::AfterFocusShowDropList() { | 816 FX_BOOL CFWL_ComboBoxImp::AfterFocusShowDropList() { |
834 if (!m_bNeedShowList) { | 817 if (!m_bNeedShowList) { |
835 return FALSE; | 818 return FALSE; |
836 } | 819 } |
837 if (m_pEdit) { | 820 if (m_pEdit) { |
838 MatchEditText(); | 821 MatchEditText(); |
839 } | 822 } |
840 ShowDropList(TRUE); | 823 ShowDropList(TRUE); |
841 m_bNeedShowList = FALSE; | 824 m_bNeedShowList = FALSE; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 m_pEdit->Update(); | 1048 m_pEdit->Update(); |
1066 } | 1049 } |
1067 } | 1050 } |
1068 void CFWL_ComboBoxImp::ReSetTheme() { | 1051 void CFWL_ComboBoxImp::ReSetTheme() { |
1069 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 1052 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
1070 if (!pTheme) { | 1053 if (!pTheme) { |
1071 pTheme = GetAvailableTheme(); | 1054 pTheme = GetAvailableTheme(); |
1072 m_pProperties->m_pThemeProvider = pTheme; | 1055 m_pProperties->m_pThemeProvider = pTheme; |
1073 } | 1056 } |
1074 if (m_pListBox) { | 1057 if (m_pListBox) { |
1075 if (!m_pListBox->GetThemeProvider() && pTheme->IsValidWidget(m_pListBox)) { | 1058 if (!m_pListBox->GetThemeProvider() && |
| 1059 pTheme->IsValidWidget(m_pListBox.get())) { |
1076 m_pListBox->SetThemeProvider(pTheme); | 1060 m_pListBox->SetThemeProvider(pTheme); |
1077 } | 1061 } |
1078 } | 1062 } |
1079 if (m_pEdit) { | 1063 if (m_pEdit) { |
1080 if (!m_pEdit->GetThemeProvider() && pTheme->IsValidWidget(m_pEdit)) { | 1064 if (!m_pEdit->GetThemeProvider() && pTheme->IsValidWidget(m_pEdit.get())) { |
1081 m_pEdit->SetThemeProvider(pTheme); | 1065 m_pEdit->SetThemeProvider(pTheme); |
1082 } | 1066 } |
1083 } | 1067 } |
1084 } | 1068 } |
1085 void CFWL_ComboBoxImp::ReSetEditAlignment() { | 1069 void CFWL_ComboBoxImp::ReSetEditAlignment() { |
1086 if (!m_pEdit) | 1070 if (!m_pEdit) |
1087 return; | 1071 return; |
1088 FX_DWORD dwStylExes = m_pProperties->m_dwStyleExes; | 1072 FX_DWORD dwStylExes = m_pProperties->m_dwStyleExes; |
1089 FX_DWORD dwAdd = 0; | 1073 FX_DWORD dwAdd = 0; |
1090 switch (dwStylExes & FWL_STYLEEXT_CMB_EditHAlignMask) { | 1074 switch (dwStylExes & FWL_STYLEEXT_CMB_EditHAlignMask) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 } | 1148 } |
1165 void CFWL_ComboBoxImp::InitProxyForm() { | 1149 void CFWL_ComboBoxImp::InitProxyForm() { |
1166 if (m_pForm) | 1150 if (m_pForm) |
1167 return; | 1151 return; |
1168 if (!m_pListBox) | 1152 if (!m_pListBox) |
1169 return; | 1153 return; |
1170 CFWL_WidgetImpProperties propForm; | 1154 CFWL_WidgetImpProperties propForm; |
1171 propForm.m_pOwner = m_pInterface; | 1155 propForm.m_pOwner = m_pInterface; |
1172 propForm.m_dwStyles = FWL_WGTSTYLE_Popup; | 1156 propForm.m_dwStyles = FWL_WGTSTYLE_Popup; |
1173 propForm.m_dwStates = FWL_WGTSTATE_Invisible; | 1157 propForm.m_dwStates = FWL_WGTSTATE_Invisible; |
1174 m_pProxy = new CFWL_FormProxyImp(propForm, m_pListBox); | 1158 m_pProxy = new CFWL_FormProxyImp(propForm, m_pListBox.get()); |
1175 m_pForm = IFWL_Form::Create(); | 1159 m_pForm = new IFWL_Form; |
1176 m_pProxy->SetInterface(m_pForm); | 1160 m_pProxy->SetInterface(m_pForm); |
1177 m_pForm->SetImpl(m_pProxy); | 1161 m_pForm->SetImpl(m_pProxy); |
1178 m_pProxy->Initialize(); | 1162 m_pProxy->Initialize(); |
1179 m_pListBox->SetParent(m_pForm); | 1163 m_pListBox->SetParent(m_pForm); |
1180 m_pListProxyDelegate = new CFWL_ComboProxyImpDelegate(m_pForm, this); | 1164 m_pListProxyDelegate = new CFWL_ComboProxyImpDelegate(m_pForm, this); |
1181 m_pProxy->SetDelegate(m_pListProxyDelegate); | 1165 m_pProxy->SetDelegate(m_pListProxyDelegate); |
1182 } | 1166 } |
1183 FWL_ERR CFWL_ComboBoxImp::DisForm_Initialize() { | 1167 FWL_ERR CFWL_ComboBoxImp::DisForm_Initialize() { |
1184 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) | 1168 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) |
1185 return FWL_WGTSTATE_Invisible; // Ditto. | 1169 return FWL_WGTSTATE_Invisible; // Ditto. |
1186 m_pDelegate = new CFWL_ComboBoxImpDelegate(this); | 1170 m_pDelegate = new CFWL_ComboBoxImpDelegate(this); |
1187 DisForm_InitComboList(); | 1171 DisForm_InitComboList(); |
1188 DisForm_InitComboEdit(); | 1172 DisForm_InitComboEdit(); |
1189 return FWL_ERR_Succeeded; | 1173 return FWL_ERR_Succeeded; |
1190 } | 1174 } |
1191 void CFWL_ComboBoxImp::DisForm_InitComboList() { | 1175 void CFWL_ComboBoxImp::DisForm_InitComboList() { |
1192 if (m_pListBox) { | 1176 if (m_pListBox) { |
1193 return; | 1177 return; |
1194 } | 1178 } |
1195 CFWL_WidgetImpProperties prop; | 1179 CFWL_WidgetImpProperties prop; |
1196 prop.m_pParent = m_pInterface; | 1180 prop.m_pParent = m_pInterface; |
1197 prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; | 1181 prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; |
1198 prop.m_dwStates = FWL_WGTSTATE_Invisible; | 1182 prop.m_dwStates = FWL_WGTSTATE_Invisible; |
1199 prop.m_pDataProvider = m_pProperties->m_pDataProvider; | 1183 prop.m_pDataProvider = m_pProperties->m_pDataProvider; |
1200 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; | 1184 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; |
1201 CFWL_ComboListImp* pList = new CFWL_ComboListImp(prop, m_pInterface); | 1185 CFWL_ComboListImp* pList = new CFWL_ComboListImp(prop, m_pInterface); |
1202 m_pListBox = IFWL_ListBox::Create(); | 1186 m_pListBox.reset(new IFWL_ListBox); |
1203 pList->SetInterface(m_pListBox); | 1187 pList->SetInterface(m_pListBox.get()); |
1204 m_pListBox->SetImpl(pList); | 1188 m_pListBox->SetImpl(pList); |
1205 pList->Initialize(); | 1189 pList->Initialize(); |
1206 } | 1190 } |
1207 void CFWL_ComboBoxImp::DisForm_InitComboEdit() { | 1191 void CFWL_ComboBoxImp::DisForm_InitComboEdit() { |
1208 if (m_pEdit) { | 1192 if (m_pEdit) { |
1209 return; | 1193 return; |
1210 } | 1194 } |
1211 CFWL_WidgetImpProperties prop; | 1195 CFWL_WidgetImpProperties prop; |
1212 prop.m_pParent = m_pInterface; | 1196 prop.m_pParent = m_pInterface; |
1213 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; | 1197 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; |
1214 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) == 0) { | 1198 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) == 0) { |
1215 } | 1199 } |
1216 CFWL_ComboEditImp* pEdit = new CFWL_ComboEditImp(prop, m_pInterface); | 1200 CFWL_ComboEditImp* pEdit = new CFWL_ComboEditImp(prop, m_pInterface); |
1217 m_pEdit = IFWL_Edit::Create(); | 1201 m_pEdit.reset(new IFWL_Edit); |
1218 pEdit->SetInterface(m_pEdit); | 1202 pEdit->SetInterface(m_pEdit.get()); |
1219 m_pEdit->SetImpl(pEdit); | 1203 m_pEdit->SetImpl(pEdit); |
1220 pEdit->Initialize(); | 1204 pEdit->Initialize(); |
1221 pEdit->SetOuter(m_pInterface); | 1205 pEdit->SetOuter(m_pInterface); |
1222 } | 1206 } |
1223 void CFWL_ComboBoxImp::DisForm_ShowDropList(FX_BOOL bActivate) { | 1207 void CFWL_ComboBoxImp::DisForm_ShowDropList(FX_BOOL bActivate) { |
1224 FX_BOOL bDropList = DisForm_IsDropListShowed(); | 1208 FX_BOOL bDropList = DisForm_IsDropListShowed(); |
1225 if (bDropList == bActivate) { | 1209 if (bDropList == bActivate) { |
1226 return; | 1210 return; |
1227 } | 1211 } |
1228 if (bActivate) { | 1212 if (bActivate) { |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 const CFX_Matrix* pMatrix) { | 1470 const CFX_Matrix* pMatrix) { |
1487 return m_pOwner->DrawWidget(pGraphics, pMatrix); | 1471 return m_pOwner->DrawWidget(pGraphics, pMatrix); |
1488 } | 1472 } |
1489 void CFWL_ComboBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, | 1473 void CFWL_ComboBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, |
1490 FX_BOOL bSet) { | 1474 FX_BOOL bSet) { |
1491 IFWL_Target* pDstTarget = pMsg->m_pDstTarget; | 1475 IFWL_Target* pDstTarget = pMsg->m_pDstTarget; |
1492 IFWL_Target* pSrcTarget = pMsg->m_pSrcTarget; | 1476 IFWL_Target* pSrcTarget = pMsg->m_pSrcTarget; |
1493 FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); | 1477 FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); |
1494 if (bSet) { | 1478 if (bSet) { |
1495 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; | 1479 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; |
1496 if (bDropDown && pSrcTarget != m_pOwner->m_pListBox) { | 1480 if (bDropDown && pSrcTarget != m_pOwner->m_pListBox.get()) { |
1497 if (!m_pOwner->m_pEdit) | 1481 if (!m_pOwner->m_pEdit) |
1498 return; | 1482 return; |
1499 static_cast<CFWL_ComboEditImp*>(m_pOwner->m_pEdit->GetImpl()) | 1483 static_cast<CFWL_ComboEditImp*>(m_pOwner->m_pEdit->GetImpl()) |
1500 ->SetSelected(); | 1484 ->SetSelected(); |
1501 } else { | 1485 } else { |
1502 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1486 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
1503 } | 1487 } |
1504 } else { | 1488 } else { |
1505 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; | 1489 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; |
1506 if (bDropDown && pDstTarget != m_pOwner->m_pListBox) { | 1490 if (bDropDown && pDstTarget != m_pOwner->m_pListBox.get()) { |
1507 if (!m_pOwner->m_pEdit) | 1491 if (!m_pOwner->m_pEdit) |
1508 return; | 1492 return; |
1509 static_cast<CFWL_ComboEditImp*>(m_pOwner->m_pEdit->GetImpl()) | 1493 static_cast<CFWL_ComboEditImp*>(m_pOwner->m_pEdit->GetImpl()) |
1510 ->FlagFocus(FALSE); | 1494 ->FlagFocus(FALSE); |
1511 static_cast<CFWL_ComboEditImp*>(m_pOwner->m_pEdit->GetImpl()) | 1495 static_cast<CFWL_ComboEditImp*>(m_pOwner->m_pEdit->GetImpl()) |
1512 ->ClearSelected(); | 1496 ->ClearSelected(); |
1513 } else { | 1497 } else { |
1514 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1498 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
1515 } | 1499 } |
1516 } | 1500 } |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1706 m_pOwner->DisForm_ShowDropList(TRUE); | 1690 m_pOwner->DisForm_ShowDropList(TRUE); |
1707 } | 1691 } |
1708 } | 1692 } |
1709 } | 1693 } |
1710 void CFWL_ComboBoxImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg, | 1694 void CFWL_ComboBoxImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg, |
1711 FX_BOOL bSet) { | 1695 FX_BOOL bSet) { |
1712 if (bSet) { | 1696 if (bSet) { |
1713 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; | 1697 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; |
1714 if ((m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) { | 1698 if ((m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) { |
1715 CFWL_MsgSetFocus msg; | 1699 CFWL_MsgSetFocus msg; |
1716 msg.m_pDstTarget = m_pOwner->m_pEdit; | 1700 msg.m_pDstTarget = m_pOwner->m_pEdit.get(); |
1717 msg.m_pSrcTarget = NULL; | 1701 msg.m_pSrcTarget = NULL; |
1718 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); | 1702 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); |
1719 pDelegate->OnProcessMessage(&msg); | 1703 pDelegate->OnProcessMessage(&msg); |
1720 } | 1704 } |
1721 } else { | 1705 } else { |
1722 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; | 1706 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; |
1723 m_pOwner->DisForm_ShowDropList(FALSE); | 1707 m_pOwner->DisForm_ShowDropList(FALSE); |
1724 CFWL_MsgKillFocus msg; | 1708 CFWL_MsgKillFocus msg; |
1725 msg.m_pDstTarget = NULL; | 1709 msg.m_pDstTarget = NULL; |
1726 msg.m_pSrcTarget = m_pOwner->m_pEdit; | 1710 msg.m_pSrcTarget = m_pOwner->m_pEdit.get(); |
1727 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); | 1711 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); |
1728 pDelegate->OnProcessMessage(&msg); | 1712 pDelegate->OnProcessMessage(&msg); |
1729 } | 1713 } |
1730 } | 1714 } |
1731 void CFWL_ComboBoxImpDelegate::DisForm_OnKey(CFWL_MsgKey* pMsg) { | 1715 void CFWL_ComboBoxImpDelegate::DisForm_OnKey(CFWL_MsgKey* pMsg) { |
1732 FX_DWORD dwKeyCode = pMsg->m_dwKeyCode; | 1716 FX_DWORD dwKeyCode = pMsg->m_dwKeyCode; |
1733 FX_BOOL bUp = dwKeyCode == FWL_VKEY_Up; | 1717 FX_BOOL bUp = dwKeyCode == FWL_VKEY_Up; |
1734 FX_BOOL bDown = dwKeyCode == FWL_VKEY_Down; | 1718 FX_BOOL bDown = dwKeyCode == FWL_VKEY_Down; |
1735 if (bUp || bDown) { | 1719 if (bUp || bDown) { |
1736 CFWL_ComboListImp* pComboList = | 1720 CFWL_ComboListImp* pComboList = |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 m_pComboBox->ShowDropList(FALSE); | 1890 m_pComboBox->ShowDropList(FALSE); |
1907 } | 1891 } |
1908 void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg, | 1892 void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg, |
1909 FX_BOOL bSet) { | 1893 FX_BOOL bSet) { |
1910 if (!bSet) { | 1894 if (!bSet) { |
1911 if (pMsg->m_pSetFocus == NULL) { | 1895 if (pMsg->m_pSetFocus == NULL) { |
1912 m_pComboBox->ShowDropList(FALSE); | 1896 m_pComboBox->ShowDropList(FALSE); |
1913 } | 1897 } |
1914 } | 1898 } |
1915 } | 1899 } |
OLD | NEW |