| 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/fxfa/app/xfa_ffchoicelist.h" | 7 #include "xfa/fxfa/app/xfa_ffchoicelist.h" |
| 8 | 8 |
| 9 #include "xfa/fwl/basewidget/ifwl_edit.h" | 9 #include "xfa/fwl/basewidget/ifwl_edit.h" |
| 10 #include "xfa/fwl/core/ifwl_app.h" | 10 #include "xfa/fwl/core/ifwl_app.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); | 39 IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); |
| 40 pNoteDriver->RegisterEventTarget(pWidget, pWidget); | 40 pNoteDriver->RegisterEventTarget(pWidget, pWidget); |
| 41 m_pOldDelegate = m_pNormalWidget->SetDelegate(this); | 41 m_pOldDelegate = m_pNormalWidget->SetDelegate(this); |
| 42 m_pNormalWidget->LockUpdate(); | 42 m_pNormalWidget->LockUpdate(); |
| 43 CFX_WideStringArray wsLabelArray; | 43 CFX_WideStringArray wsLabelArray; |
| 44 m_pDataAcc->GetChoiceListItems(wsLabelArray, FALSE); | 44 m_pDataAcc->GetChoiceListItems(wsLabelArray, FALSE); |
| 45 int32_t iItems = wsLabelArray.GetSize(); | 45 int32_t iItems = wsLabelArray.GetSize(); |
| 46 for (int32_t i = 0; i < iItems; i++) { | 46 for (int32_t i = 0; i < iItems; i++) { |
| 47 pListBox->AddString(wsLabelArray[i]); | 47 pListBox->AddString(wsLabelArray[i]); |
| 48 } | 48 } |
| 49 FX_DWORD dwExtendedStyle = FWL_STYLEEXT_LTB_ShowScrollBarFocus; | 49 uint32_t dwExtendedStyle = FWL_STYLEEXT_LTB_ShowScrollBarFocus; |
| 50 if (m_pDataAcc->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { | 50 if (m_pDataAcc->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { |
| 51 dwExtendedStyle |= FWL_STYLEEXT_LTB_MultiSelection; | 51 dwExtendedStyle |= FWL_STYLEEXT_LTB_MultiSelection; |
| 52 } | 52 } |
| 53 dwExtendedStyle |= GetAlignment(); | 53 dwExtendedStyle |= GetAlignment(); |
| 54 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); | 54 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); |
| 55 CFX_Int32Array iSelArray; | 55 CFX_Int32Array iSelArray; |
| 56 m_pDataAcc->GetSelectedItems(iSelArray); | 56 m_pDataAcc->GetSelectedItems(iSelArray); |
| 57 int32_t iSelCount = iSelArray.GetSize(); | 57 int32_t iSelCount = iSelArray.GetSize(); |
| 58 for (int32_t j = 0; j < iSelCount; j++) { | 58 for (int32_t j = 0; j < iSelCount; j++) { |
| 59 FWL_HLISTITEM item = pListBox->GetItem(iSelArray[j]); | 59 FWL_HLISTITEM item = pListBox->GetItem(iSelArray[j]); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 if (!(pListBox->GetItemStates(hlistItem) && FWL_ITEMSTATE_LTB_Selected)) { | 93 if (!(pListBox->GetItemStates(hlistItem) && FWL_ITEMSTATE_LTB_Selected)) { |
| 94 break; | 94 break; |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 if (iIndex == iSels) { | 97 if (iIndex == iSels) { |
| 98 return FALSE; | 98 return FALSE; |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 return TRUE; | 101 return TRUE; |
| 102 } | 102 } |
| 103 FX_DWORD CXFA_FFListBox::GetAlignment() { | 103 uint32_t CXFA_FFListBox::GetAlignment() { |
| 104 FX_DWORD dwExtendedStyle = 0; | 104 uint32_t dwExtendedStyle = 0; |
| 105 if (CXFA_Para para = m_pDataAcc->GetPara()) { | 105 if (CXFA_Para para = m_pDataAcc->GetPara()) { |
| 106 int32_t iHorz = para.GetHorizontalAlign(); | 106 int32_t iHorz = para.GetHorizontalAlign(); |
| 107 switch (iHorz) { | 107 switch (iHorz) { |
| 108 case XFA_ATTRIBUTEENUM_Center: | 108 case XFA_ATTRIBUTEENUM_Center: |
| 109 dwExtendedStyle |= FWL_STYLEEXT_LTB_CenterAlign; | 109 dwExtendedStyle |= FWL_STYLEEXT_LTB_CenterAlign; |
| 110 break; | 110 break; |
| 111 case XFA_ATTRIBUTEENUM_Justify: | 111 case XFA_ATTRIBUTEENUM_Justify: |
| 112 break; | 112 break; |
| 113 case XFA_ATTRIBUTEENUM_JustifyAll: | 113 case XFA_ATTRIBUTEENUM_JustifyAll: |
| 114 break; | 114 break; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 ->DeleteString(((CFWL_ListBox*)m_pNormalWidget)->GetItem(nIndex)); | 178 ->DeleteString(((CFWL_ListBox*)m_pNormalWidget)->GetItem(nIndex)); |
| 179 } | 179 } |
| 180 m_pNormalWidget->Update(); | 180 m_pNormalWidget->Update(); |
| 181 AddInvalidateRect(); | 181 AddInvalidateRect(); |
| 182 } | 182 } |
| 183 int32_t CXFA_FFListBox::OnProcessMessage(CFWL_Message* pMessage) { | 183 int32_t CXFA_FFListBox::OnProcessMessage(CFWL_Message* pMessage) { |
| 184 return m_pOldDelegate->OnProcessMessage(pMessage); | 184 return m_pOldDelegate->OnProcessMessage(pMessage); |
| 185 } | 185 } |
| 186 FWL_ERR CXFA_FFListBox::OnProcessEvent(CFWL_Event* pEvent) { | 186 FWL_ERR CXFA_FFListBox::OnProcessEvent(CFWL_Event* pEvent) { |
| 187 CXFA_FFField::OnProcessEvent(pEvent); | 187 CXFA_FFField::OnProcessEvent(pEvent); |
| 188 FX_DWORD dwEventID = pEvent->GetClassID(); | 188 uint32_t dwEventID = pEvent->GetClassID(); |
| 189 switch (dwEventID) { | 189 switch (dwEventID) { |
| 190 case FWL_EVTHASH_LTB_SelChanged: { | 190 case FWL_EVTHASH_LTB_SelChanged: { |
| 191 CFX_Int32Array arrSels; | 191 CFX_Int32Array arrSels; |
| 192 OnSelectChanged(m_pNormalWidget->GetWidget(), arrSels); | 192 OnSelectChanged(m_pNormalWidget->GetWidget(), arrSels); |
| 193 break; | 193 break; |
| 194 } | 194 } |
| 195 default: {} | 195 default: {} |
| 196 } | 196 } |
| 197 return m_pOldDelegate->OnProcessEvent(pEvent); | 197 return m_pOldDelegate->OnProcessEvent(pEvent); |
| 198 } | 198 } |
| 199 FWL_ERR CXFA_FFListBox::OnDrawWidget(CFX_Graphics* pGraphics, | 199 FWL_ERR CXFA_FFListBox::OnDrawWidget(CFX_Graphics* pGraphics, |
| 200 const CFX_Matrix* pMatrix) { | 200 const CFX_Matrix* pMatrix) { |
| 201 return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); | 201 return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); |
| 202 } | 202 } |
| 203 | 203 |
| 204 CXFA_FFComboBox::CXFA_FFComboBox(CXFA_FFPageView* pPageView, | 204 CXFA_FFComboBox::CXFA_FFComboBox(CXFA_FFPageView* pPageView, |
| 205 CXFA_WidgetAcc* pDataAcc) | 205 CXFA_WidgetAcc* pDataAcc) |
| 206 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(NULL) {} | 206 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(NULL) {} |
| 207 | 207 |
| 208 CXFA_FFComboBox::~CXFA_FFComboBox() {} | 208 CXFA_FFComboBox::~CXFA_FFComboBox() {} |
| 209 | 209 |
| 210 FX_BOOL CXFA_FFComboBox::GetBBox(CFX_RectF& rtBox, | 210 FX_BOOL CXFA_FFComboBox::GetBBox(CFX_RectF& rtBox, |
| 211 FX_DWORD dwStatus, | 211 uint32_t dwStatus, |
| 212 FX_BOOL bDrawFocus) { | 212 FX_BOOL bDrawFocus) { |
| 213 if (bDrawFocus) | 213 if (bDrawFocus) |
| 214 return FALSE; | 214 return FALSE; |
| 215 return CXFA_FFWidget::GetBBox(rtBox, dwStatus); | 215 return CXFA_FFWidget::GetBBox(rtBox, dwStatus); |
| 216 } | 216 } |
| 217 | 217 |
| 218 FX_BOOL CXFA_FFComboBox::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { | 218 FX_BOOL CXFA_FFComboBox::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { |
| 219 if (!m_pNormalWidget) { | 219 if (!m_pNormalWidget) { |
| 220 return FALSE; | 220 return FALSE; |
| 221 } | 221 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 254 } |
| 255 UpdateWidgetProperty(); | 255 UpdateWidgetProperty(); |
| 256 m_pNormalWidget->UnlockUpdate(); | 256 m_pNormalWidget->UnlockUpdate(); |
| 257 return CXFA_FFField::LoadWidget(); | 257 return CXFA_FFField::LoadWidget(); |
| 258 } | 258 } |
| 259 void CXFA_FFComboBox::UpdateWidgetProperty() { | 259 void CXFA_FFComboBox::UpdateWidgetProperty() { |
| 260 CFWL_ComboBox* pComboBox = (CFWL_ComboBox*)m_pNormalWidget; | 260 CFWL_ComboBox* pComboBox = (CFWL_ComboBox*)m_pNormalWidget; |
| 261 if (!pComboBox) { | 261 if (!pComboBox) { |
| 262 return; | 262 return; |
| 263 } | 263 } |
| 264 FX_DWORD dwExtendedStyle = 0; | 264 uint32_t dwExtendedStyle = 0; |
| 265 FX_DWORD dwEditStyles = | 265 uint32_t dwEditStyles = |
| 266 FWL_STYLEEXT_EDT_ReadOnly | FWL_STYLEEXT_EDT_LastLineHeight; | 266 FWL_STYLEEXT_EDT_ReadOnly | FWL_STYLEEXT_EDT_LastLineHeight; |
| 267 dwExtendedStyle |= UpdateUIProperty(); | 267 dwExtendedStyle |= UpdateUIProperty(); |
| 268 if (m_pDataAcc->IsChoiceListAllowTextEntry()) { | 268 if (m_pDataAcc->IsChoiceListAllowTextEntry()) { |
| 269 dwEditStyles &= ~FWL_STYLEEXT_EDT_ReadOnly; | 269 dwEditStyles &= ~FWL_STYLEEXT_EDT_ReadOnly; |
| 270 dwExtendedStyle |= FWL_STYLEEXT_CMB_DropDown; | 270 dwExtendedStyle |= FWL_STYLEEXT_CMB_DropDown; |
| 271 } | 271 } |
| 272 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || | 272 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || |
| 273 !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { | 273 !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { |
| 274 dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly; | 274 dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly; |
| 275 dwExtendedStyle |= FWL_STYLEEXT_CMB_ReadOnly; | 275 dwExtendedStyle |= FWL_STYLEEXT_CMB_ReadOnly; |
| 276 } | 276 } |
| 277 dwExtendedStyle |= GetAlignment(); | 277 dwExtendedStyle |= GetAlignment(); |
| 278 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); | 278 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); |
| 279 if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { | 279 if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { |
| 280 dwEditStyles |= FWL_STYLEEXT_EDT_AutoHScroll; | 280 dwEditStyles |= FWL_STYLEEXT_EDT_AutoHScroll; |
| 281 } | 281 } |
| 282 pComboBox->EditModifyStylesEx(dwEditStyles, 0xFFFFFFFF); | 282 pComboBox->EditModifyStylesEx(dwEditStyles, 0xFFFFFFFF); |
| 283 } | 283 } |
| 284 FX_BOOL CXFA_FFComboBox::OnRButtonUp(FX_DWORD dwFlags, | 284 FX_BOOL CXFA_FFComboBox::OnRButtonUp(uint32_t dwFlags, |
| 285 FX_FLOAT fx, | 285 FX_FLOAT fx, |
| 286 FX_FLOAT fy) { | 286 FX_FLOAT fy) { |
| 287 if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) | 287 if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) |
| 288 return FALSE; | 288 return FALSE; |
| 289 | 289 |
| 290 GetDoc()->GetDocProvider()->PopupMenu(this, CFX_PointF(fx, fy), nullptr); | 290 GetDoc()->GetDocProvider()->PopupMenu(this, CFX_PointF(fx, fy), nullptr); |
| 291 return TRUE; | 291 return TRUE; |
| 292 } | 292 } |
| 293 FX_BOOL CXFA_FFComboBox::OnKillFocus(CXFA_FFWidget* pNewWidget) { | 293 FX_BOOL CXFA_FFComboBox::OnKillFocus(CXFA_FFWidget* pNewWidget) { |
| 294 FX_BOOL flag = ProcessCommittedData(); | 294 FX_BOOL flag = ProcessCommittedData(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 324 } | 324 } |
| 325 return FALSE; | 325 return FALSE; |
| 326 } | 326 } |
| 327 void CXFA_FFComboBox::FWLEventSelChange(CXFA_EventParam* pParam) { | 327 void CXFA_FFComboBox::FWLEventSelChange(CXFA_EventParam* pParam) { |
| 328 pParam->m_eType = XFA_EVENT_Change; | 328 pParam->m_eType = XFA_EVENT_Change; |
| 329 pParam->m_pTarget = m_pDataAcc; | 329 pParam->m_pTarget = m_pDataAcc; |
| 330 CFWL_ComboBox* pFWLcombobox = ((CFWL_ComboBox*)m_pNormalWidget); | 330 CFWL_ComboBox* pFWLcombobox = ((CFWL_ComboBox*)m_pNormalWidget); |
| 331 pFWLcombobox->GetEditText(pParam->m_wsNewText); | 331 pFWLcombobox->GetEditText(pParam->m_wsNewText); |
| 332 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, pParam); | 332 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, pParam); |
| 333 } | 333 } |
| 334 FX_DWORD CXFA_FFComboBox::GetAlignment() { | 334 uint32_t CXFA_FFComboBox::GetAlignment() { |
| 335 FX_DWORD dwExtendedStyle = 0; | 335 uint32_t dwExtendedStyle = 0; |
| 336 if (CXFA_Para para = m_pDataAcc->GetPara()) { | 336 if (CXFA_Para para = m_pDataAcc->GetPara()) { |
| 337 int32_t iHorz = para.GetHorizontalAlign(); | 337 int32_t iHorz = para.GetHorizontalAlign(); |
| 338 switch (iHorz) { | 338 switch (iHorz) { |
| 339 case XFA_ATTRIBUTEENUM_Center: | 339 case XFA_ATTRIBUTEENUM_Center: |
| 340 dwExtendedStyle |= | 340 dwExtendedStyle |= |
| 341 FWL_STYLEEXT_CMB_EditHCenter | FWL_STYLEEXT_CMB_ListItemCenterAlign; | 341 FWL_STYLEEXT_CMB_EditHCenter | FWL_STYLEEXT_CMB_ListItemCenterAlign; |
| 342 break; | 342 break; |
| 343 case XFA_ATTRIBUTEENUM_Justify: | 343 case XFA_ATTRIBUTEENUM_Justify: |
| 344 dwExtendedStyle |= FWL_STYLEEXT_CMB_EditJustified; | 344 dwExtendedStyle |= FWL_STYLEEXT_CMB_EditJustified; |
| 345 break; | 345 break; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 eParam.m_eType = XFA_EVENT_PostOpen; | 493 eParam.m_eType = XFA_EVENT_PostOpen; |
| 494 eParam.m_pTarget = m_pDataAcc; | 494 eParam.m_pTarget = m_pDataAcc; |
| 495 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_PostOpen, &eParam); | 495 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_PostOpen, &eParam); |
| 496 } | 496 } |
| 497 | 497 |
| 498 int32_t CXFA_FFComboBox::OnProcessMessage(CFWL_Message* pMessage) { | 498 int32_t CXFA_FFComboBox::OnProcessMessage(CFWL_Message* pMessage) { |
| 499 return m_pOldDelegate->OnProcessMessage(pMessage); | 499 return m_pOldDelegate->OnProcessMessage(pMessage); |
| 500 } | 500 } |
| 501 FWL_ERR CXFA_FFComboBox::OnProcessEvent(CFWL_Event* pEvent) { | 501 FWL_ERR CXFA_FFComboBox::OnProcessEvent(CFWL_Event* pEvent) { |
| 502 CXFA_FFField::OnProcessEvent(pEvent); | 502 CXFA_FFField::OnProcessEvent(pEvent); |
| 503 FX_DWORD dwEventID = pEvent->GetClassID(); | 503 uint32_t dwEventID = pEvent->GetClassID(); |
| 504 switch (dwEventID) { | 504 switch (dwEventID) { |
| 505 case FWL_EVTHASH_CMB_SelChanged: { | 505 case FWL_EVTHASH_CMB_SelChanged: { |
| 506 CFWL_EvtCmbSelChanged* postEvent = (CFWL_EvtCmbSelChanged*)pEvent; | 506 CFWL_EvtCmbSelChanged* postEvent = (CFWL_EvtCmbSelChanged*)pEvent; |
| 507 OnSelectChanged(m_pNormalWidget->GetWidget(), postEvent->iArraySels, | 507 OnSelectChanged(m_pNormalWidget->GetWidget(), postEvent->iArraySels, |
| 508 postEvent->bLButtonUp); | 508 postEvent->bLButtonUp); |
| 509 break; | 509 break; |
| 510 } | 510 } |
| 511 case FWL_EVTHASH_CMB_EditChanged: { | 511 case FWL_EVTHASH_CMB_EditChanged: { |
| 512 CFX_WideString wsChanged; | 512 CFX_WideString wsChanged; |
| 513 OnTextChanged(m_pNormalWidget->GetWidget(), wsChanged); | 513 OnTextChanged(m_pNormalWidget->GetWidget(), wsChanged); |
| 514 break; | 514 break; |
| 515 } | 515 } |
| 516 case FWL_EVTHASH_CMB_PreDropDown: { | 516 case FWL_EVTHASH_CMB_PreDropDown: { |
| 517 OnPreOpen(m_pNormalWidget->GetWidget()); | 517 OnPreOpen(m_pNormalWidget->GetWidget()); |
| 518 break; | 518 break; |
| 519 } | 519 } |
| 520 case FWL_EVTHASH_CMB_PostDropDown: { | 520 case FWL_EVTHASH_CMB_PostDropDown: { |
| 521 OnPostOpen(m_pNormalWidget->GetWidget()); | 521 OnPostOpen(m_pNormalWidget->GetWidget()); |
| 522 break; | 522 break; |
| 523 } | 523 } |
| 524 default: {} | 524 default: {} |
| 525 } | 525 } |
| 526 return m_pOldDelegate->OnProcessEvent(pEvent); | 526 return m_pOldDelegate->OnProcessEvent(pEvent); |
| 527 } | 527 } |
| 528 FWL_ERR CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics, | 528 FWL_ERR CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics, |
| 529 const CFX_Matrix* pMatrix) { | 529 const CFX_Matrix* pMatrix) { |
| 530 return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); | 530 return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); |
| 531 } | 531 } |
| OLD | NEW |