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_combobox.h" | 7 #include "xfa/fwl/core/ifwl_combobox.h" |
8 | 8 |
9 #include "third_party/base/ptr_util.h" | 9 #include "third_party/base/ptr_util.h" |
10 #include "xfa/fde/cfde_txtedtengine.h" | 10 #include "xfa/fde/cfde_txtedtengine.h" |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 if (m_pWidgetMgr->IsFormDisabled()) { | 458 if (m_pWidgetMgr->IsFormDisabled()) { |
459 return DisForm_ShowDropList(bActivate); | 459 return DisForm_ShowDropList(bActivate); |
460 } | 460 } |
461 FX_BOOL bDropList = IsDropListShowed(); | 461 FX_BOOL bDropList = IsDropListShowed(); |
462 if (bDropList == bActivate) { | 462 if (bDropList == bActivate) { |
463 return; | 463 return; |
464 } | 464 } |
465 if (!m_pForm) { | 465 if (!m_pForm) { |
466 InitProxyForm(); | 466 InitProxyForm(); |
467 } | 467 } |
468 m_pListProxyDelegate->Reset(); | 468 static_cast<CFWL_ComboProxyImpDelegate*>(m_pForm->GetDelegate())->Reset(); |
469 if (bActivate) { | 469 if (bActivate) { |
470 m_pListBox->ChangeSelected(m_iCurSel); | 470 m_pListBox->ChangeSelected(m_iCurSel); |
471 ReSetListItemAlignment(); | 471 ReSetListItemAlignment(); |
472 uint32_t dwStyleAdd = m_pProperties->m_dwStyleExes & | 472 uint32_t dwStyleAdd = m_pProperties->m_dwStyleExes & |
473 (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw); | 473 (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw); |
474 m_pListBox->ModifyStylesEx(dwStyleAdd, 0); | 474 m_pListBox->ModifyStylesEx(dwStyleAdd, 0); |
475 m_pListBox->GetWidgetRect(m_rtList, TRUE); | 475 m_pListBox->GetWidgetRect(m_rtList, TRUE); |
476 FX_FLOAT fHeight = GetListHeight(); | 476 FX_FLOAT fHeight = GetListHeight(); |
477 if (fHeight > 0) { | 477 if (fHeight > 0) { |
478 if (m_rtList.height > GetListHeight()) { | 478 if (m_rtList.height > GetListHeight()) { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 if (!m_pListBox) | 694 if (!m_pListBox) |
695 return; | 695 return; |
696 | 696 |
697 CFWL_WidgetImpProperties propForm; | 697 CFWL_WidgetImpProperties propForm; |
698 propForm.m_pOwner = this; | 698 propForm.m_pOwner = this; |
699 propForm.m_dwStyles = FWL_WGTSTYLE_Popup; | 699 propForm.m_dwStyles = FWL_WGTSTYLE_Popup; |
700 propForm.m_dwStates = FWL_WGTSTATE_Invisible; | 700 propForm.m_dwStates = FWL_WGTSTATE_Invisible; |
701 | 701 |
702 m_pForm = new IFWL_FormProxy(m_pOwnerApp, propForm, m_pListBox.get()); | 702 m_pForm = new IFWL_FormProxy(m_pOwnerApp, propForm, m_pListBox.get()); |
703 m_pListBox->SetParent(m_pForm); | 703 m_pListBox->SetParent(m_pForm); |
704 m_pListProxyDelegate = new CFWL_ComboProxyImpDelegate(m_pForm, this); | 704 m_pForm->SetDelegate( |
705 m_pForm->SetCurrentDelegate(m_pListProxyDelegate); | 705 pdfium::MakeUnique<CFWL_ComboProxyImpDelegate>(m_pForm, this)); |
706 } | 706 } |
707 | 707 |
708 void IFWL_ComboBox::DisForm_InitComboList() { | 708 void IFWL_ComboBox::DisForm_InitComboList() { |
709 if (m_pListBox) | 709 if (m_pListBox) |
710 return; | 710 return; |
711 | 711 |
712 CFWL_WidgetImpProperties prop; | 712 CFWL_WidgetImpProperties prop; |
713 prop.m_pParent = this; | 713 prop.m_pParent = this; |
714 prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; | 714 prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; |
715 prop.m_dwStates = FWL_WGTSTATE_Invisible; | 715 prop.m_dwStates = FWL_WGTSTATE_Invisible; |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 m_pOwner->m_iCurSel = iCurSel; | 1134 m_pOwner->m_iCurSel = iCurSel; |
1135 if (bDropDown && m_pOwner->m_pEdit) { | 1135 if (bDropDown && m_pOwner->m_pEdit) { |
1136 m_pOwner->SynchrEditText(m_pOwner->m_iCurSel); | 1136 m_pOwner->SynchrEditText(m_pOwner->m_iCurSel); |
1137 } else { | 1137 } else { |
1138 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1138 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
1139 } | 1139 } |
1140 return; | 1140 return; |
1141 } | 1141 } |
1142 FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); | 1142 FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); |
1143 if (bDropDown) | 1143 if (bDropDown) |
1144 m_pOwner->m_pEdit->GetCurrentDelegate()->OnProcessMessage(pMsg); | 1144 m_pOwner->m_pEdit->GetDelegate()->OnProcessMessage(pMsg); |
1145 } | 1145 } |
1146 | 1146 |
1147 void CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage( | 1147 void CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage( |
1148 CFWL_Message* pMessage) { | 1148 CFWL_Message* pMessage) { |
1149 if (!pMessage) | 1149 if (!pMessage) |
1150 return; | 1150 return; |
1151 | 1151 |
1152 FX_BOOL backDefault = TRUE; | 1152 FX_BOOL backDefault = TRUE; |
1153 switch (pMessage->GetClassID()) { | 1153 switch (pMessage->GetClassID()) { |
1154 case CFWL_MessageType::SetFocus: { | 1154 case CFWL_MessageType::SetFocus: { |
(...skipping 28 matching lines...) Expand all Loading... |
1183 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); | 1183 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); |
1184 if (pKey->m_dwCmd == FWL_KeyCommand::KeyUp) | 1184 if (pKey->m_dwCmd == FWL_KeyCommand::KeyUp) |
1185 break; | 1185 break; |
1186 if (m_pOwner->DisForm_IsDropListShowed() && | 1186 if (m_pOwner->DisForm_IsDropListShowed() && |
1187 pKey->m_dwCmd == FWL_KeyCommand::KeyDown) { | 1187 pKey->m_dwCmd == FWL_KeyCommand::KeyDown) { |
1188 FX_BOOL bListKey = pKey->m_dwKeyCode == FWL_VKEY_Up || | 1188 FX_BOOL bListKey = pKey->m_dwKeyCode == FWL_VKEY_Up || |
1189 pKey->m_dwKeyCode == FWL_VKEY_Down || | 1189 pKey->m_dwKeyCode == FWL_VKEY_Down || |
1190 pKey->m_dwKeyCode == FWL_VKEY_Return || | 1190 pKey->m_dwKeyCode == FWL_VKEY_Return || |
1191 pKey->m_dwKeyCode == FWL_VKEY_Escape; | 1191 pKey->m_dwKeyCode == FWL_VKEY_Escape; |
1192 if (bListKey) { | 1192 if (bListKey) { |
1193 m_pOwner->m_pListBox->GetCurrentDelegate()->OnProcessMessage( | 1193 m_pOwner->m_pListBox->GetDelegate()->OnProcessMessage(pMessage); |
1194 pMessage); | |
1195 break; | 1194 break; |
1196 } | 1195 } |
1197 } | 1196 } |
1198 DisForm_OnKey(pKey); | 1197 DisForm_OnKey(pKey); |
1199 break; | 1198 break; |
1200 } | 1199 } |
1201 default: | 1200 default: |
1202 break; | 1201 break; |
1203 } | 1202 } |
1204 if (backDefault) | 1203 if (backDefault) |
(...skipping 19 matching lines...) Expand all Loading... |
1224 } | 1223 } |
1225 | 1224 |
1226 void CFWL_ComboBoxImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg, | 1225 void CFWL_ComboBoxImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg, |
1227 FX_BOOL bSet) { | 1226 FX_BOOL bSet) { |
1228 if (bSet) { | 1227 if (bSet) { |
1229 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; | 1228 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; |
1230 if ((m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) { | 1229 if ((m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) { |
1231 CFWL_MsgSetFocus msg; | 1230 CFWL_MsgSetFocus msg; |
1232 msg.m_pDstTarget = m_pOwner->m_pEdit.get(); | 1231 msg.m_pDstTarget = m_pOwner->m_pEdit.get(); |
1233 msg.m_pSrcTarget = nullptr; | 1232 msg.m_pSrcTarget = nullptr; |
1234 m_pOwner->m_pEdit->GetCurrentDelegate()->OnProcessMessage(&msg); | 1233 m_pOwner->m_pEdit->GetDelegate()->OnProcessMessage(&msg); |
1235 } | 1234 } |
1236 } else { | 1235 } else { |
1237 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; | 1236 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; |
1238 m_pOwner->DisForm_ShowDropList(FALSE); | 1237 m_pOwner->DisForm_ShowDropList(FALSE); |
1239 CFWL_MsgKillFocus msg; | 1238 CFWL_MsgKillFocus msg; |
1240 msg.m_pDstTarget = nullptr; | 1239 msg.m_pDstTarget = nullptr; |
1241 msg.m_pSrcTarget = m_pOwner->m_pEdit.get(); | 1240 msg.m_pSrcTarget = m_pOwner->m_pEdit.get(); |
1242 m_pOwner->m_pEdit->GetCurrentDelegate()->OnProcessMessage(&msg); | 1241 m_pOwner->m_pEdit->GetDelegate()->OnProcessMessage(&msg); |
1243 } | 1242 } |
1244 } | 1243 } |
1245 | 1244 |
1246 void CFWL_ComboBoxImpDelegate::DisForm_OnKey(CFWL_MsgKey* pMsg) { | 1245 void CFWL_ComboBoxImpDelegate::DisForm_OnKey(CFWL_MsgKey* pMsg) { |
1247 uint32_t dwKeyCode = pMsg->m_dwKeyCode; | 1246 uint32_t dwKeyCode = pMsg->m_dwKeyCode; |
1248 const bool bUp = dwKeyCode == FWL_VKEY_Up; | 1247 const bool bUp = dwKeyCode == FWL_VKEY_Up; |
1249 const bool bDown = dwKeyCode == FWL_VKEY_Down; | 1248 const bool bDown = dwKeyCode == FWL_VKEY_Down; |
1250 if (bUp || bDown) { | 1249 if (bUp || bDown) { |
1251 IFWL_ComboList* pComboList = m_pOwner->m_pListBox.get(); | 1250 IFWL_ComboList* pComboList = m_pOwner->m_pListBox.get(); |
1252 int32_t iCount = pComboList->CountItems(); | 1251 int32_t iCount = pComboList->CountItems(); |
(...skipping 23 matching lines...) Expand all Loading... |
1276 iCurSel--; | 1275 iCurSel--; |
1277 } else { | 1276 } else { |
1278 iCurSel++; | 1277 iCurSel++; |
1279 } | 1278 } |
1280 } | 1279 } |
1281 m_pOwner->m_iCurSel = iCurSel; | 1280 m_pOwner->m_iCurSel = iCurSel; |
1282 m_pOwner->SynchrEditText(m_pOwner->m_iCurSel); | 1281 m_pOwner->SynchrEditText(m_pOwner->m_iCurSel); |
1283 return; | 1282 return; |
1284 } | 1283 } |
1285 if (m_pOwner->m_pEdit) | 1284 if (m_pOwner->m_pEdit) |
1286 m_pOwner->m_pEdit->GetCurrentDelegate()->OnProcessMessage(pMsg); | 1285 m_pOwner->m_pEdit->GetDelegate()->OnProcessMessage(pMsg); |
1287 } | 1286 } |
1288 | 1287 |
1289 CFWL_ComboProxyImpDelegate::CFWL_ComboProxyImpDelegate(IFWL_Form* pForm, | 1288 CFWL_ComboProxyImpDelegate::CFWL_ComboProxyImpDelegate(IFWL_Form* pForm, |
1290 IFWL_ComboBox* pComboBox) | 1289 IFWL_ComboBox* pComboBox) |
1291 : m_bLButtonDown(FALSE), | 1290 : m_bLButtonDown(FALSE), |
1292 m_bLButtonUpSelf(FALSE), | 1291 m_bLButtonUpSelf(FALSE), |
1293 m_fStartPos(0), | 1292 m_fStartPos(0), |
1294 m_pForm(pForm), | 1293 m_pForm(pForm), |
1295 m_pComboBox(pComboBox) {} | 1294 m_pComboBox(pComboBox) {} |
1296 | 1295 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 } | 1390 } |
1392 | 1391 |
1393 void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg, | 1392 void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg, |
1394 FX_BOOL bSet) { | 1393 FX_BOOL bSet) { |
1395 if (!bSet) { | 1394 if (!bSet) { |
1396 if (!pMsg->m_pSetFocus) { | 1395 if (!pMsg->m_pSetFocus) { |
1397 m_pComboBox->ShowDropList(FALSE); | 1396 m_pComboBox->ShowDropList(FALSE); |
1398 } | 1397 } |
1399 } | 1398 } |
1400 } | 1399 } |
OLD | NEW |