| 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 "xfa/fde/cfde_txtedtengine.h" | 9 #include "xfa/fde/cfde_txtedtengine.h" |
| 10 #include "xfa/fde/tto/fde_textout.h" | 10 #include "xfa/fde/tto/fde_textout.h" |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 | 711 |
| 712 CFWL_WidgetImpProperties propForm; | 712 CFWL_WidgetImpProperties propForm; |
| 713 propForm.m_pOwner = this; | 713 propForm.m_pOwner = this; |
| 714 propForm.m_dwStyles = FWL_WGTSTYLE_Popup; | 714 propForm.m_dwStyles = FWL_WGTSTYLE_Popup; |
| 715 propForm.m_dwStates = FWL_WGTSTATE_Invisible; | 715 propForm.m_dwStates = FWL_WGTSTATE_Invisible; |
| 716 | 716 |
| 717 m_pForm = new IFWL_FormProxy(m_pOwnerApp, propForm, m_pListBox.get()); | 717 m_pForm = new IFWL_FormProxy(m_pOwnerApp, propForm, m_pListBox.get()); |
| 718 m_pForm->Initialize(); | 718 m_pForm->Initialize(); |
| 719 m_pListBox->SetParent(m_pForm); | 719 m_pListBox->SetParent(m_pForm); |
| 720 m_pListProxyDelegate = new CFWL_ComboProxyImpDelegate(m_pForm, this); | 720 m_pListProxyDelegate = new CFWL_ComboProxyImpDelegate(m_pForm, this); |
| 721 m_pForm->SetDelegate(m_pListProxyDelegate); | 721 m_pForm->SetCurrentDelegate(m_pListProxyDelegate); |
| 722 } | 722 } |
| 723 | 723 |
| 724 void IFWL_ComboBox::DisForm_InitComboList() { | 724 void IFWL_ComboBox::DisForm_InitComboList() { |
| 725 if (m_pListBox) | 725 if (m_pListBox) |
| 726 return; | 726 return; |
| 727 | 727 |
| 728 CFWL_WidgetImpProperties prop; | 728 CFWL_WidgetImpProperties prop; |
| 729 prop.m_pParent = this; | 729 prop.m_pParent = this; |
| 730 prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; | 730 prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; |
| 731 prop.m_dwStates = FWL_WGTSTATE_Invisible; | 731 prop.m_dwStates = FWL_WGTSTATE_Invisible; |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 } | 1151 } |
| 1152 m_pOwner->m_iCurSel = iCurSel; | 1152 m_pOwner->m_iCurSel = iCurSel; |
| 1153 if (bDropDown && m_pOwner->m_pEdit) { | 1153 if (bDropDown && m_pOwner->m_pEdit) { |
| 1154 m_pOwner->SynchrEditText(m_pOwner->m_iCurSel); | 1154 m_pOwner->SynchrEditText(m_pOwner->m_iCurSel); |
| 1155 } else { | 1155 } else { |
| 1156 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1156 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
| 1157 } | 1157 } |
| 1158 return; | 1158 return; |
| 1159 } | 1159 } |
| 1160 FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); | 1160 FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); |
| 1161 if (bDropDown) { | 1161 if (bDropDown) |
| 1162 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(nullptr); | 1162 m_pOwner->m_pEdit->GetCurrentDelegate()->OnProcessMessage(pMsg); |
| 1163 pDelegate->OnProcessMessage(pMsg); | |
| 1164 } | |
| 1165 } | 1163 } |
| 1166 | 1164 |
| 1167 void CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage( | 1165 void CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage( |
| 1168 CFWL_Message* pMessage) { | 1166 CFWL_Message* pMessage) { |
| 1169 if (!pMessage) | 1167 if (!pMessage) |
| 1170 return; | 1168 return; |
| 1171 | 1169 |
| 1172 FX_BOOL backDefault = TRUE; | 1170 FX_BOOL backDefault = TRUE; |
| 1173 switch (pMessage->GetClassID()) { | 1171 switch (pMessage->GetClassID()) { |
| 1174 case CFWL_MessageType::SetFocus: { | 1172 case CFWL_MessageType::SetFocus: { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1203 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); | 1201 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); |
| 1204 if (pKey->m_dwCmd == FWL_KeyCommand::KeyUp) | 1202 if (pKey->m_dwCmd == FWL_KeyCommand::KeyUp) |
| 1205 break; | 1203 break; |
| 1206 if (m_pOwner->DisForm_IsDropListShowed() && | 1204 if (m_pOwner->DisForm_IsDropListShowed() && |
| 1207 pKey->m_dwCmd == FWL_KeyCommand::KeyDown) { | 1205 pKey->m_dwCmd == FWL_KeyCommand::KeyDown) { |
| 1208 FX_BOOL bListKey = pKey->m_dwKeyCode == FWL_VKEY_Up || | 1206 FX_BOOL bListKey = pKey->m_dwKeyCode == FWL_VKEY_Up || |
| 1209 pKey->m_dwKeyCode == FWL_VKEY_Down || | 1207 pKey->m_dwKeyCode == FWL_VKEY_Down || |
| 1210 pKey->m_dwKeyCode == FWL_VKEY_Return || | 1208 pKey->m_dwKeyCode == FWL_VKEY_Return || |
| 1211 pKey->m_dwKeyCode == FWL_VKEY_Escape; | 1209 pKey->m_dwKeyCode == FWL_VKEY_Escape; |
| 1212 if (bListKey) { | 1210 if (bListKey) { |
| 1213 IFWL_WidgetDelegate* pDelegate = | 1211 m_pOwner->m_pListBox->GetCurrentDelegate()->OnProcessMessage( |
| 1214 m_pOwner->m_pListBox->SetDelegate(nullptr); | 1212 pMessage); |
| 1215 pDelegate->OnProcessMessage(pMessage); | |
| 1216 break; | 1213 break; |
| 1217 } | 1214 } |
| 1218 } | 1215 } |
| 1219 DisForm_OnKey(pKey); | 1216 DisForm_OnKey(pKey); |
| 1220 break; | 1217 break; |
| 1221 } | 1218 } |
| 1222 default: | 1219 default: |
| 1223 break; | 1220 break; |
| 1224 } | 1221 } |
| 1225 if (backDefault) | 1222 if (backDefault) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1245 } | 1242 } |
| 1246 | 1243 |
| 1247 void CFWL_ComboBoxImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg, | 1244 void CFWL_ComboBoxImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg, |
| 1248 FX_BOOL bSet) { | 1245 FX_BOOL bSet) { |
| 1249 if (bSet) { | 1246 if (bSet) { |
| 1250 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; | 1247 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; |
| 1251 if ((m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) { | 1248 if ((m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) { |
| 1252 CFWL_MsgSetFocus msg; | 1249 CFWL_MsgSetFocus msg; |
| 1253 msg.m_pDstTarget = m_pOwner->m_pEdit.get(); | 1250 msg.m_pDstTarget = m_pOwner->m_pEdit.get(); |
| 1254 msg.m_pSrcTarget = nullptr; | 1251 msg.m_pSrcTarget = nullptr; |
| 1255 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(nullptr); | 1252 m_pOwner->m_pEdit->GetCurrentDelegate()->OnProcessMessage(&msg); |
| 1256 pDelegate->OnProcessMessage(&msg); | |
| 1257 } | 1253 } |
| 1258 } else { | 1254 } else { |
| 1259 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; | 1255 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; |
| 1260 m_pOwner->DisForm_ShowDropList(FALSE); | 1256 m_pOwner->DisForm_ShowDropList(FALSE); |
| 1261 CFWL_MsgKillFocus msg; | 1257 CFWL_MsgKillFocus msg; |
| 1262 msg.m_pDstTarget = nullptr; | 1258 msg.m_pDstTarget = nullptr; |
| 1263 msg.m_pSrcTarget = m_pOwner->m_pEdit.get(); | 1259 msg.m_pSrcTarget = m_pOwner->m_pEdit.get(); |
| 1264 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(nullptr); | 1260 m_pOwner->m_pEdit->GetCurrentDelegate()->OnProcessMessage(&msg); |
| 1265 pDelegate->OnProcessMessage(&msg); | |
| 1266 } | 1261 } |
| 1267 } | 1262 } |
| 1268 | 1263 |
| 1269 void CFWL_ComboBoxImpDelegate::DisForm_OnKey(CFWL_MsgKey* pMsg) { | 1264 void CFWL_ComboBoxImpDelegate::DisForm_OnKey(CFWL_MsgKey* pMsg) { |
| 1270 uint32_t dwKeyCode = pMsg->m_dwKeyCode; | 1265 uint32_t dwKeyCode = pMsg->m_dwKeyCode; |
| 1271 const bool bUp = dwKeyCode == FWL_VKEY_Up; | 1266 const bool bUp = dwKeyCode == FWL_VKEY_Up; |
| 1272 const bool bDown = dwKeyCode == FWL_VKEY_Down; | 1267 const bool bDown = dwKeyCode == FWL_VKEY_Down; |
| 1273 if (bUp || bDown) { | 1268 if (bUp || bDown) { |
| 1274 IFWL_ComboList* pComboList = m_pOwner->m_pListBox.get(); | 1269 IFWL_ComboList* pComboList = m_pOwner->m_pListBox.get(); |
| 1275 int32_t iCount = pComboList->CountItems(); | 1270 int32_t iCount = pComboList->CountItems(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1298 if (bUp) { | 1293 if (bUp) { |
| 1299 iCurSel--; | 1294 iCurSel--; |
| 1300 } else { | 1295 } else { |
| 1301 iCurSel++; | 1296 iCurSel++; |
| 1302 } | 1297 } |
| 1303 } | 1298 } |
| 1304 m_pOwner->m_iCurSel = iCurSel; | 1299 m_pOwner->m_iCurSel = iCurSel; |
| 1305 m_pOwner->SynchrEditText(m_pOwner->m_iCurSel); | 1300 m_pOwner->SynchrEditText(m_pOwner->m_iCurSel); |
| 1306 return; | 1301 return; |
| 1307 } | 1302 } |
| 1308 if (m_pOwner->m_pEdit) { | 1303 if (m_pOwner->m_pEdit) |
| 1309 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(nullptr); | 1304 m_pOwner->m_pEdit->GetCurrentDelegate()->OnProcessMessage(pMsg); |
| 1310 pDelegate->OnProcessMessage(pMsg); | |
| 1311 } | |
| 1312 } | 1305 } |
| 1313 | 1306 |
| 1314 CFWL_ComboProxyImpDelegate::CFWL_ComboProxyImpDelegate(IFWL_Form* pForm, | 1307 CFWL_ComboProxyImpDelegate::CFWL_ComboProxyImpDelegate(IFWL_Form* pForm, |
| 1315 IFWL_ComboBox* pComboBox) | 1308 IFWL_ComboBox* pComboBox) |
| 1316 : m_bLButtonDown(FALSE), | 1309 : m_bLButtonDown(FALSE), |
| 1317 m_bLButtonUpSelf(FALSE), | 1310 m_bLButtonUpSelf(FALSE), |
| 1318 m_fStartPos(0), | 1311 m_fStartPos(0), |
| 1319 m_pForm(pForm), | 1312 m_pForm(pForm), |
| 1320 m_pComboBox(pComboBox) {} | 1313 m_pComboBox(pComboBox) {} |
| 1321 | 1314 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 } | 1409 } |
| 1417 | 1410 |
| 1418 void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg, | 1411 void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg, |
| 1419 FX_BOOL bSet) { | 1412 FX_BOOL bSet) { |
| 1420 if (!bSet) { | 1413 if (!bSet) { |
| 1421 if (!pMsg->m_pSetFocus) { | 1414 if (!pMsg->m_pSetFocus) { |
| 1422 m_pComboBox->ShowDropList(FALSE); | 1415 m_pComboBox->ShowDropList(FALSE); |
| 1423 } | 1416 } |
| 1424 } | 1417 } |
| 1425 } | 1418 } |
| OLD | NEW |