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/core/cfwl_combobox.h" | 9 #include "xfa/fwl/core/cfwl_combobox.h" |
10 #include "xfa/fwl/core/cfwl_listbox.h" | 10 #include "xfa/fwl/core/cfwl_listbox.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(nullptr) {} | 24 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(nullptr) {} |
25 | 25 |
26 CXFA_FFListBox::~CXFA_FFListBox() { | 26 CXFA_FFListBox::~CXFA_FFListBox() { |
27 if (m_pNormalWidget) { | 27 if (m_pNormalWidget) { |
28 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); | 28 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); |
29 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); | 29 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); |
30 pNoteDriver->UnregisterEventTarget(pWidget); | 30 pNoteDriver->UnregisterEventTarget(pWidget); |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 FX_BOOL CXFA_FFListBox::LoadWidget() { | 34 bool CXFA_FFListBox::LoadWidget() { |
35 CFWL_ListBox* pListBox = new CFWL_ListBox(GetFWLApp()); | 35 CFWL_ListBox* pListBox = new CFWL_ListBox(GetFWLApp()); |
36 pListBox->Initialize(); | 36 pListBox->Initialize(); |
37 pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll | FWL_WGTSTYLE_NoBackground, | 37 pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll | FWL_WGTSTYLE_NoBackground, |
38 0xFFFFFFFF); | 38 0xFFFFFFFF); |
39 m_pNormalWidget = (CFWL_Widget*)pListBox; | 39 m_pNormalWidget = (CFWL_Widget*)pListBox; |
40 m_pNormalWidget->SetLayoutItem(this); | 40 m_pNormalWidget->SetLayoutItem(this); |
41 | 41 |
42 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); | 42 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); |
43 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); | 43 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); |
44 pNoteDriver->RegisterEventTarget(pWidget, pWidget); | 44 pNoteDriver->RegisterEventTarget(pWidget, pWidget); |
45 | 45 |
46 m_pOldDelegate = m_pNormalWidget->GetDelegate(); | 46 m_pOldDelegate = m_pNormalWidget->GetDelegate(); |
47 m_pNormalWidget->SetDelegate(this); | 47 m_pNormalWidget->SetDelegate(this); |
48 m_pNormalWidget->LockUpdate(); | 48 m_pNormalWidget->LockUpdate(); |
49 | 49 |
50 CFX_WideStringArray wsLabelArray; | 50 CFX_WideStringArray wsLabelArray; |
51 m_pDataAcc->GetChoiceListItems(wsLabelArray, FALSE); | 51 m_pDataAcc->GetChoiceListItems(wsLabelArray, false); |
52 int32_t iItems = wsLabelArray.GetSize(); | 52 int32_t iItems = wsLabelArray.GetSize(); |
53 for (int32_t i = 0; i < iItems; i++) { | 53 for (int32_t i = 0; i < iItems; i++) { |
54 pListBox->AddString(wsLabelArray[i].AsStringC()); | 54 pListBox->AddString(wsLabelArray[i].AsStringC()); |
55 } | 55 } |
56 uint32_t dwExtendedStyle = FWL_STYLEEXT_LTB_ShowScrollBarFocus; | 56 uint32_t dwExtendedStyle = FWL_STYLEEXT_LTB_ShowScrollBarFocus; |
57 if (m_pDataAcc->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { | 57 if (m_pDataAcc->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { |
58 dwExtendedStyle |= FWL_STYLEEXT_LTB_MultiSelection; | 58 dwExtendedStyle |= FWL_STYLEEXT_LTB_MultiSelection; |
59 } | 59 } |
60 dwExtendedStyle |= GetAlignment(); | 60 dwExtendedStyle |= GetAlignment(); |
61 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); | 61 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); |
62 CFX_Int32Array iSelArray; | 62 CFX_Int32Array iSelArray; |
63 m_pDataAcc->GetSelectedItems(iSelArray); | 63 m_pDataAcc->GetSelectedItems(iSelArray); |
64 int32_t iSelCount = iSelArray.GetSize(); | 64 int32_t iSelCount = iSelArray.GetSize(); |
65 for (int32_t j = 0; j < iSelCount; j++) { | 65 for (int32_t j = 0; j < iSelCount; j++) { |
66 IFWL_ListItem* item = pListBox->GetItem(iSelArray[j]); | 66 IFWL_ListItem* item = pListBox->GetItem(iSelArray[j]); |
67 pListBox->SetSelItem(item, TRUE); | 67 pListBox->SetSelItem(item, true); |
68 } | 68 } |
69 m_pNormalWidget->UnlockUpdate(); | 69 m_pNormalWidget->UnlockUpdate(); |
70 return CXFA_FFField::LoadWidget(); | 70 return CXFA_FFField::LoadWidget(); |
71 } | 71 } |
72 | 72 |
73 FX_BOOL CXFA_FFListBox::OnKillFocus(CXFA_FFWidget* pNewFocus) { | 73 bool CXFA_FFListBox::OnKillFocus(CXFA_FFWidget* pNewFocus) { |
74 if (!ProcessCommittedData()) | 74 if (!ProcessCommittedData()) |
75 UpdateFWLData(); | 75 UpdateFWLData(); |
76 CXFA_FFField::OnKillFocus(pNewFocus); | 76 CXFA_FFField::OnKillFocus(pNewFocus); |
77 return TRUE; | 77 return true; |
78 } | 78 } |
79 | 79 |
80 FX_BOOL CXFA_FFListBox::CommitData() { | 80 bool CXFA_FFListBox::CommitData() { |
81 CFWL_ListBox* pListBox = static_cast<CFWL_ListBox*>(m_pNormalWidget); | 81 CFWL_ListBox* pListBox = static_cast<CFWL_ListBox*>(m_pNormalWidget); |
82 int32_t iSels = pListBox->CountSelItems(); | 82 int32_t iSels = pListBox->CountSelItems(); |
83 CFX_Int32Array iSelArray; | 83 CFX_Int32Array iSelArray; |
84 for (int32_t i = 0; i < iSels; ++i) | 84 for (int32_t i = 0; i < iSels; ++i) |
85 iSelArray.Add(pListBox->GetSelIndex(i)); | 85 iSelArray.Add(pListBox->GetSelIndex(i)); |
86 m_pDataAcc->SetSelectedItems(iSelArray, true, FALSE, TRUE); | 86 m_pDataAcc->SetSelectedItems(iSelArray, true, false, true); |
87 return TRUE; | 87 return true; |
88 } | 88 } |
89 | 89 |
90 FX_BOOL CXFA_FFListBox::IsDataChanged() { | 90 bool CXFA_FFListBox::IsDataChanged() { |
91 CFX_Int32Array iSelArray; | 91 CFX_Int32Array iSelArray; |
92 m_pDataAcc->GetSelectedItems(iSelArray); | 92 m_pDataAcc->GetSelectedItems(iSelArray); |
93 int32_t iOldSels = iSelArray.GetSize(); | 93 int32_t iOldSels = iSelArray.GetSize(); |
94 CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget; | 94 CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget; |
95 int32_t iSels = pListBox->CountSelItems(); | 95 int32_t iSels = pListBox->CountSelItems(); |
96 if (iOldSels != iSels) | 96 if (iOldSels != iSels) |
97 return TRUE; | 97 return true; |
98 | 98 |
99 for (int32_t i = 0; i < iSels; ++i) { | 99 for (int32_t i = 0; i < iSels; ++i) { |
100 IFWL_ListItem* hlistItem = pListBox->GetItem(iSelArray[i]); | 100 IFWL_ListItem* hlistItem = pListBox->GetItem(iSelArray[i]); |
101 if (!(pListBox->GetItemStates(hlistItem) & FWL_ITEMSTATE_LTB_Selected)) | 101 if (!(pListBox->GetItemStates(hlistItem) & FWL_ITEMSTATE_LTB_Selected)) |
102 return TRUE; | 102 return true; |
103 } | 103 } |
104 return FALSE; | 104 return false; |
105 } | 105 } |
106 | 106 |
107 uint32_t CXFA_FFListBox::GetAlignment() { | 107 uint32_t CXFA_FFListBox::GetAlignment() { |
108 uint32_t dwExtendedStyle = 0; | 108 uint32_t dwExtendedStyle = 0; |
109 if (CXFA_Para para = m_pDataAcc->GetPara()) { | 109 if (CXFA_Para para = m_pDataAcc->GetPara()) { |
110 int32_t iHorz = para.GetHorizontalAlign(); | 110 int32_t iHorz = para.GetHorizontalAlign(); |
111 switch (iHorz) { | 111 switch (iHorz) { |
112 case XFA_ATTRIBUTEENUM_Center: | 112 case XFA_ATTRIBUTEENUM_Center: |
113 dwExtendedStyle |= FWL_STYLEEXT_LTB_CenterAlign; | 113 dwExtendedStyle |= FWL_STYLEEXT_LTB_CenterAlign; |
114 break; | 114 break; |
115 case XFA_ATTRIBUTEENUM_Justify: | 115 case XFA_ATTRIBUTEENUM_Justify: |
116 break; | 116 break; |
117 case XFA_ATTRIBUTEENUM_JustifyAll: | 117 case XFA_ATTRIBUTEENUM_JustifyAll: |
118 break; | 118 break; |
119 case XFA_ATTRIBUTEENUM_Radix: | 119 case XFA_ATTRIBUTEENUM_Radix: |
120 break; | 120 break; |
121 case XFA_ATTRIBUTEENUM_Right: | 121 case XFA_ATTRIBUTEENUM_Right: |
122 dwExtendedStyle |= FWL_STYLEEXT_LTB_RightAlign; | 122 dwExtendedStyle |= FWL_STYLEEXT_LTB_RightAlign; |
123 break; | 123 break; |
124 default: | 124 default: |
125 dwExtendedStyle |= FWL_STYLEEXT_LTB_LeftAlign; | 125 dwExtendedStyle |= FWL_STYLEEXT_LTB_LeftAlign; |
126 break; | 126 break; |
127 } | 127 } |
128 } | 128 } |
129 return dwExtendedStyle; | 129 return dwExtendedStyle; |
130 } | 130 } |
131 FX_BOOL CXFA_FFListBox::UpdateFWLData() { | 131 bool CXFA_FFListBox::UpdateFWLData() { |
132 if (!m_pNormalWidget) { | 132 if (!m_pNormalWidget) { |
133 return FALSE; | 133 return false; |
134 } | 134 } |
135 CFWL_ListBox* pListBox = ((CFWL_ListBox*)m_pNormalWidget); | 135 CFWL_ListBox* pListBox = ((CFWL_ListBox*)m_pNormalWidget); |
136 CFX_ArrayTemplate<IFWL_ListItem*> selItemArray; | 136 CFX_ArrayTemplate<IFWL_ListItem*> selItemArray; |
137 CFX_Int32Array iSelArray; | 137 CFX_Int32Array iSelArray; |
138 m_pDataAcc->GetSelectedItems(iSelArray); | 138 m_pDataAcc->GetSelectedItems(iSelArray); |
139 int32_t iSelCount = iSelArray.GetSize(); | 139 int32_t iSelCount = iSelArray.GetSize(); |
140 for (int32_t j = 0; j < iSelCount; j++) { | 140 for (int32_t j = 0; j < iSelCount; j++) { |
141 IFWL_ListItem* lpItemSel = pListBox->GetSelItem(iSelArray[j]); | 141 IFWL_ListItem* lpItemSel = pListBox->GetSelItem(iSelArray[j]); |
142 selItemArray.Add(lpItemSel); | 142 selItemArray.Add(lpItemSel); |
143 } | 143 } |
144 pListBox->SetSelItem(pListBox->GetSelItem(-1), FALSE); | 144 pListBox->SetSelItem(pListBox->GetSelItem(-1), false); |
145 for (int32_t i = 0; i < iSelCount; i++) { | 145 for (int32_t i = 0; i < iSelCount; i++) { |
146 ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(selItemArray[i], TRUE); | 146 ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(selItemArray[i], true); |
147 } | 147 } |
148 m_pNormalWidget->Update(); | 148 m_pNormalWidget->Update(); |
149 return TRUE; | 149 return true; |
150 } | 150 } |
151 void CXFA_FFListBox::OnSelectChanged(IFWL_Widget* pWidget, | 151 void CXFA_FFListBox::OnSelectChanged(IFWL_Widget* pWidget, |
152 const CFX_Int32Array& arrSels) { | 152 const CFX_Int32Array& arrSels) { |
153 CXFA_EventParam eParam; | 153 CXFA_EventParam eParam; |
154 eParam.m_eType = XFA_EVENT_Change; | 154 eParam.m_eType = XFA_EVENT_Change; |
155 eParam.m_pTarget = m_pDataAcc; | 155 eParam.m_pTarget = m_pDataAcc; |
156 m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); | 156 m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); |
157 CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget; | 157 CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget; |
158 int32_t iSels = pListBox->CountSelItems(); | 158 int32_t iSels = pListBox->CountSelItems(); |
159 if (iSels > 0) { | 159 if (iSels > 0) { |
160 pListBox->GetItemText(pListBox->GetSelItem(0), eParam.m_wsNewText); | 160 pListBox->GetItemText(pListBox->GetSelItem(0), eParam.m_wsNewText); |
161 } | 161 } |
162 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); | 162 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); |
163 } | 163 } |
164 void CXFA_FFListBox::SetItemState(int32_t nIndex, FX_BOOL bSelected) { | 164 void CXFA_FFListBox::SetItemState(int32_t nIndex, bool bSelected) { |
165 IFWL_ListItem* item = ((CFWL_ListBox*)m_pNormalWidget)->GetSelItem(nIndex); | 165 IFWL_ListItem* item = ((CFWL_ListBox*)m_pNormalWidget)->GetSelItem(nIndex); |
166 ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(item, bSelected); | 166 ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(item, bSelected); |
167 m_pNormalWidget->Update(); | 167 m_pNormalWidget->Update(); |
168 AddInvalidateRect(); | 168 AddInvalidateRect(); |
169 } | 169 } |
170 void CXFA_FFListBox::InsertItem(const CFX_WideStringC& wsLabel, | 170 void CXFA_FFListBox::InsertItem(const CFX_WideStringC& wsLabel, |
171 int32_t nIndex) { | 171 int32_t nIndex) { |
172 CFX_WideString wsTemp(wsLabel); | 172 CFX_WideString wsTemp(wsLabel); |
173 ((CFWL_ListBox*)m_pNormalWidget)->AddString(wsTemp.AsStringC()); | 173 ((CFWL_ListBox*)m_pNormalWidget)->AddString(wsTemp.AsStringC()); |
174 m_pNormalWidget->Update(); | 174 m_pNormalWidget->Update(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 const CFX_Matrix* pMatrix) { | 206 const CFX_Matrix* pMatrix) { |
207 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); | 207 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); |
208 } | 208 } |
209 | 209 |
210 CXFA_FFComboBox::CXFA_FFComboBox(CXFA_FFPageView* pPageView, | 210 CXFA_FFComboBox::CXFA_FFComboBox(CXFA_FFPageView* pPageView, |
211 CXFA_WidgetAcc* pDataAcc) | 211 CXFA_WidgetAcc* pDataAcc) |
212 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(nullptr) {} | 212 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(nullptr) {} |
213 | 213 |
214 CXFA_FFComboBox::~CXFA_FFComboBox() {} | 214 CXFA_FFComboBox::~CXFA_FFComboBox() {} |
215 | 215 |
216 FX_BOOL CXFA_FFComboBox::GetBBox(CFX_RectF& rtBox, | 216 bool CXFA_FFComboBox::GetBBox(CFX_RectF& rtBox, |
217 uint32_t dwStatus, | 217 uint32_t dwStatus, |
218 FX_BOOL bDrawFocus) { | 218 bool bDrawFocus) { |
219 if (bDrawFocus) | 219 if (bDrawFocus) |
220 return FALSE; | 220 return false; |
221 return CXFA_FFWidget::GetBBox(rtBox, dwStatus); | 221 return CXFA_FFWidget::GetBBox(rtBox, dwStatus); |
222 } | 222 } |
223 | 223 |
224 FX_BOOL CXFA_FFComboBox::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { | 224 bool CXFA_FFComboBox::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { |
225 if (!m_pNormalWidget) { | 225 if (!m_pNormalWidget) { |
226 return FALSE; | 226 return false; |
227 } | 227 } |
228 CFX_RectF rtWidget; | 228 CFX_RectF rtWidget; |
229 ((CFWL_ComboBox*)m_pNormalWidget)->GetBBox(rtWidget); | 229 ((CFWL_ComboBox*)m_pNormalWidget)->GetBBox(rtWidget); |
230 if (rtWidget.Contains(fx, fy)) { | 230 if (rtWidget.Contains(fx, fy)) { |
231 return TRUE; | 231 return true; |
232 } | 232 } |
233 return FALSE; | 233 return false; |
234 } | 234 } |
235 FX_BOOL CXFA_FFComboBox::LoadWidget() { | 235 bool CXFA_FFComboBox::LoadWidget() { |
236 CFWL_ComboBox* pComboBox = new CFWL_ComboBox(GetFWLApp()); | 236 CFWL_ComboBox* pComboBox = new CFWL_ComboBox(GetFWLApp()); |
237 pComboBox->Initialize(); | 237 pComboBox->Initialize(); |
238 m_pNormalWidget = (CFWL_Widget*)pComboBox; | 238 m_pNormalWidget = (CFWL_Widget*)pComboBox; |
239 m_pNormalWidget->SetLayoutItem(this); | 239 m_pNormalWidget->SetLayoutItem(this); |
240 | 240 |
241 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); | 241 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); |
242 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); | 242 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); |
243 pNoteDriver->RegisterEventTarget(pWidget, pWidget); | 243 pNoteDriver->RegisterEventTarget(pWidget, pWidget); |
244 | 244 |
245 m_pOldDelegate = m_pNormalWidget->GetDelegate(); | 245 m_pOldDelegate = m_pNormalWidget->GetDelegate(); |
246 m_pNormalWidget->SetDelegate(this); | 246 m_pNormalWidget->SetDelegate(this); |
247 m_pNormalWidget->LockUpdate(); | 247 m_pNormalWidget->LockUpdate(); |
248 | 248 |
249 CFX_WideStringArray wsLabelArray; | 249 CFX_WideStringArray wsLabelArray; |
250 m_pDataAcc->GetChoiceListItems(wsLabelArray, FALSE); | 250 m_pDataAcc->GetChoiceListItems(wsLabelArray, false); |
251 int32_t iItems = wsLabelArray.GetSize(); | 251 int32_t iItems = wsLabelArray.GetSize(); |
252 for (int32_t i = 0; i < iItems; i++) { | 252 for (int32_t i = 0; i < iItems; i++) { |
253 pComboBox->AddString(wsLabelArray[i].AsStringC()); | 253 pComboBox->AddString(wsLabelArray[i].AsStringC()); |
254 } | 254 } |
255 CFX_Int32Array iSelArray; | 255 CFX_Int32Array iSelArray; |
256 m_pDataAcc->GetSelectedItems(iSelArray); | 256 m_pDataAcc->GetSelectedItems(iSelArray); |
257 int32_t iSelCount = iSelArray.GetSize(); | 257 int32_t iSelCount = iSelArray.GetSize(); |
258 if (iSelCount > 0) { | 258 if (iSelCount > 0) { |
259 pComboBox->SetCurSel(iSelArray[0]); | 259 pComboBox->SetCurSel(iSelArray[0]); |
260 } else { | 260 } else { |
(...skipping 23 matching lines...) Expand all Loading... |
284 dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly; | 284 dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly; |
285 dwExtendedStyle |= FWL_STYLEEXT_CMB_ReadOnly; | 285 dwExtendedStyle |= FWL_STYLEEXT_CMB_ReadOnly; |
286 } | 286 } |
287 dwExtendedStyle |= GetAlignment(); | 287 dwExtendedStyle |= GetAlignment(); |
288 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); | 288 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); |
289 if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { | 289 if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { |
290 dwEditStyles |= FWL_STYLEEXT_EDT_AutoHScroll; | 290 dwEditStyles |= FWL_STYLEEXT_EDT_AutoHScroll; |
291 } | 291 } |
292 pComboBox->EditModifyStylesEx(dwEditStyles, 0xFFFFFFFF); | 292 pComboBox->EditModifyStylesEx(dwEditStyles, 0xFFFFFFFF); |
293 } | 293 } |
294 FX_BOOL CXFA_FFComboBox::OnRButtonUp(uint32_t dwFlags, | 294 bool CXFA_FFComboBox::OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { |
295 FX_FLOAT fx, | |
296 FX_FLOAT fy) { | |
297 if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) | 295 if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) |
298 return FALSE; | 296 return false; |
299 | 297 |
300 GetDoc()->GetDocEnvironment()->PopupMenu(this, CFX_PointF(fx, fy)); | 298 GetDoc()->GetDocEnvironment()->PopupMenu(this, CFX_PointF(fx, fy)); |
301 return TRUE; | 299 return true; |
302 } | 300 } |
303 FX_BOOL CXFA_FFComboBox::OnKillFocus(CXFA_FFWidget* pNewWidget) { | 301 bool CXFA_FFComboBox::OnKillFocus(CXFA_FFWidget* pNewWidget) { |
304 FX_BOOL flag = ProcessCommittedData(); | 302 bool flag = ProcessCommittedData(); |
305 if (!flag) { | 303 if (!flag) { |
306 UpdateFWLData(); | 304 UpdateFWLData(); |
307 } | 305 } |
308 CXFA_FFField::OnKillFocus(pNewWidget); | 306 CXFA_FFField::OnKillFocus(pNewWidget); |
309 return TRUE; | 307 return true; |
310 } | 308 } |
311 void CXFA_FFComboBox::OpenDropDownList() { | 309 void CXFA_FFComboBox::OpenDropDownList() { |
312 ((CFWL_ComboBox*)m_pNormalWidget)->OpenDropDownList(TRUE); | 310 ((CFWL_ComboBox*)m_pNormalWidget)->OpenDropDownList(true); |
313 } | 311 } |
314 FX_BOOL CXFA_FFComboBox::CommitData() { | 312 bool CXFA_FFComboBox::CommitData() { |
315 return m_pDataAcc->SetValue(m_wsNewValue, XFA_VALUEPICTURE_Raw); | 313 return m_pDataAcc->SetValue(m_wsNewValue, XFA_VALUEPICTURE_Raw); |
316 } | 314 } |
317 FX_BOOL CXFA_FFComboBox::IsDataChanged() { | 315 bool CXFA_FFComboBox::IsDataChanged() { |
318 CFWL_ComboBox* pFWLcombobox = ((CFWL_ComboBox*)m_pNormalWidget); | 316 CFWL_ComboBox* pFWLcombobox = ((CFWL_ComboBox*)m_pNormalWidget); |
319 CFX_WideString wsText; | 317 CFX_WideString wsText; |
320 pFWLcombobox->GetEditText(wsText); | 318 pFWLcombobox->GetEditText(wsText); |
321 int32_t iCursel = pFWLcombobox->GetCurSel(); | 319 int32_t iCursel = pFWLcombobox->GetCurSel(); |
322 if (iCursel >= 0) { | 320 if (iCursel >= 0) { |
323 CFX_WideString wsSel; | 321 CFX_WideString wsSel; |
324 pFWLcombobox->GetTextByIndex(iCursel, wsSel); | 322 pFWLcombobox->GetTextByIndex(iCursel, wsSel); |
325 if (wsSel == wsText) { | 323 if (wsSel == wsText) { |
326 m_pDataAcc->GetChoiceListItem(wsText, iCursel, TRUE); | 324 m_pDataAcc->GetChoiceListItem(wsText, iCursel, true); |
327 } | 325 } |
328 } | 326 } |
329 CFX_WideString wsOldValue; | 327 CFX_WideString wsOldValue; |
330 m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Raw); | 328 m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Raw); |
331 if (wsOldValue != wsText) { | 329 if (wsOldValue != wsText) { |
332 m_wsNewValue = wsText; | 330 m_wsNewValue = wsText; |
333 return TRUE; | 331 return true; |
334 } | 332 } |
335 return FALSE; | 333 return false; |
336 } | 334 } |
337 void CXFA_FFComboBox::FWLEventSelChange(CXFA_EventParam* pParam) { | 335 void CXFA_FFComboBox::FWLEventSelChange(CXFA_EventParam* pParam) { |
338 pParam->m_eType = XFA_EVENT_Change; | 336 pParam->m_eType = XFA_EVENT_Change; |
339 pParam->m_pTarget = m_pDataAcc; | 337 pParam->m_pTarget = m_pDataAcc; |
340 CFWL_ComboBox* pFWLcombobox = ((CFWL_ComboBox*)m_pNormalWidget); | 338 CFWL_ComboBox* pFWLcombobox = ((CFWL_ComboBox*)m_pNormalWidget); |
341 pFWLcombobox->GetEditText(pParam->m_wsNewText); | 339 pFWLcombobox->GetEditText(pParam->m_wsNewText); |
342 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, pParam); | 340 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, pParam); |
343 } | 341 } |
344 uint32_t CXFA_FFComboBox::GetAlignment() { | 342 uint32_t CXFA_FFComboBox::GetAlignment() { |
345 uint32_t dwExtendedStyle = 0; | 343 uint32_t dwExtendedStyle = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
372 case XFA_ATTRIBUTEENUM_Bottom: | 370 case XFA_ATTRIBUTEENUM_Bottom: |
373 dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVFar; | 371 dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVFar; |
374 break; | 372 break; |
375 default: | 373 default: |
376 dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVNear; | 374 dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVNear; |
377 break; | 375 break; |
378 } | 376 } |
379 } | 377 } |
380 return dwExtendedStyle; | 378 return dwExtendedStyle; |
381 } | 379 } |
382 FX_BOOL CXFA_FFComboBox::UpdateFWLData() { | 380 bool CXFA_FFComboBox::UpdateFWLData() { |
383 if (!m_pNormalWidget) { | 381 if (!m_pNormalWidget) { |
384 return FALSE; | 382 return false; |
385 } | 383 } |
386 CFX_Int32Array iSelArray; | 384 CFX_Int32Array iSelArray; |
387 m_pDataAcc->GetSelectedItems(iSelArray); | 385 m_pDataAcc->GetSelectedItems(iSelArray); |
388 int32_t iSelCount = iSelArray.GetSize(); | 386 int32_t iSelCount = iSelArray.GetSize(); |
389 if (iSelCount > 0) { | 387 if (iSelCount > 0) { |
390 ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(iSelArray[0]); | 388 ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(iSelArray[0]); |
391 } else { | 389 } else { |
392 CFX_WideString wsText; | 390 CFX_WideString wsText; |
393 ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(-1); | 391 ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(-1); |
394 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw); | 392 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw); |
395 ((CFWL_ComboBox*)m_pNormalWidget)->SetEditText(wsText); | 393 ((CFWL_ComboBox*)m_pNormalWidget)->SetEditText(wsText); |
396 } | 394 } |
397 m_pNormalWidget->Update(); | 395 m_pNormalWidget->Update(); |
398 return TRUE; | 396 return true; |
399 } | 397 } |
400 FX_BOOL CXFA_FFComboBox::CanUndo() { | 398 bool CXFA_FFComboBox::CanUndo() { |
401 return m_pDataAcc->IsChoiceListAllowTextEntry() && | 399 return m_pDataAcc->IsChoiceListAllowTextEntry() && |
402 ((CFWL_ComboBox*)m_pNormalWidget)->EditCanUndo(); | 400 ((CFWL_ComboBox*)m_pNormalWidget)->EditCanUndo(); |
403 } | 401 } |
404 FX_BOOL CXFA_FFComboBox::CanRedo() { | 402 bool CXFA_FFComboBox::CanRedo() { |
405 return m_pDataAcc->IsChoiceListAllowTextEntry() && | 403 return m_pDataAcc->IsChoiceListAllowTextEntry() && |
406 ((CFWL_ComboBox*)m_pNormalWidget)->EditCanRedo(); | 404 ((CFWL_ComboBox*)m_pNormalWidget)->EditCanRedo(); |
407 } | 405 } |
408 FX_BOOL CXFA_FFComboBox::Undo() { | 406 bool CXFA_FFComboBox::Undo() { |
409 return m_pDataAcc->IsChoiceListAllowTextEntry() && | 407 return m_pDataAcc->IsChoiceListAllowTextEntry() && |
410 ((CFWL_ComboBox*)m_pNormalWidget)->EditUndo(); | 408 ((CFWL_ComboBox*)m_pNormalWidget)->EditUndo(); |
411 } | 409 } |
412 FX_BOOL CXFA_FFComboBox::Redo() { | 410 bool CXFA_FFComboBox::Redo() { |
413 return m_pDataAcc->IsChoiceListAllowTextEntry() && | 411 return m_pDataAcc->IsChoiceListAllowTextEntry() && |
414 ((CFWL_ComboBox*)m_pNormalWidget)->EditRedo(); | 412 ((CFWL_ComboBox*)m_pNormalWidget)->EditRedo(); |
415 } | 413 } |
416 FX_BOOL CXFA_FFComboBox::CanCopy() { | 414 bool CXFA_FFComboBox::CanCopy() { |
417 return ((CFWL_ComboBox*)m_pNormalWidget)->EditCanCopy(); | 415 return ((CFWL_ComboBox*)m_pNormalWidget)->EditCanCopy(); |
418 } | 416 } |
419 FX_BOOL CXFA_FFComboBox::CanCut() { | 417 bool CXFA_FFComboBox::CanCut() { |
420 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { | 418 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { |
421 return FALSE; | 419 return false; |
422 } | 420 } |
423 return m_pDataAcc->IsChoiceListAllowTextEntry() && | 421 return m_pDataAcc->IsChoiceListAllowTextEntry() && |
424 ((CFWL_ComboBox*)m_pNormalWidget)->EditCanCut(); | 422 ((CFWL_ComboBox*)m_pNormalWidget)->EditCanCut(); |
425 } | 423 } |
426 FX_BOOL CXFA_FFComboBox::CanPaste() { | 424 bool CXFA_FFComboBox::CanPaste() { |
427 return m_pDataAcc->IsChoiceListAllowTextEntry() && | 425 return m_pDataAcc->IsChoiceListAllowTextEntry() && |
428 (m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open); | 426 (m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open); |
429 } | 427 } |
430 FX_BOOL CXFA_FFComboBox::CanSelectAll() { | 428 bool CXFA_FFComboBox::CanSelectAll() { |
431 return ((CFWL_ComboBox*)m_pNormalWidget)->EditCanSelectAll(); | 429 return ((CFWL_ComboBox*)m_pNormalWidget)->EditCanSelectAll(); |
432 } | 430 } |
433 FX_BOOL CXFA_FFComboBox::Copy(CFX_WideString& wsCopy) { | 431 bool CXFA_FFComboBox::Copy(CFX_WideString& wsCopy) { |
434 return ((CFWL_ComboBox*)m_pNormalWidget)->EditCopy(wsCopy); | 432 return ((CFWL_ComboBox*)m_pNormalWidget)->EditCopy(wsCopy); |
435 } | 433 } |
436 FX_BOOL CXFA_FFComboBox::Cut(CFX_WideString& wsCut) { | 434 bool CXFA_FFComboBox::Cut(CFX_WideString& wsCut) { |
437 return m_pDataAcc->IsChoiceListAllowTextEntry() && | 435 return m_pDataAcc->IsChoiceListAllowTextEntry() && |
438 ((CFWL_ComboBox*)m_pNormalWidget)->EditCut(wsCut); | 436 ((CFWL_ComboBox*)m_pNormalWidget)->EditCut(wsCut); |
439 } | 437 } |
440 FX_BOOL CXFA_FFComboBox::Paste(const CFX_WideString& wsPaste) { | 438 bool CXFA_FFComboBox::Paste(const CFX_WideString& wsPaste) { |
441 return m_pDataAcc->IsChoiceListAllowTextEntry() && | 439 return m_pDataAcc->IsChoiceListAllowTextEntry() && |
442 ((CFWL_ComboBox*)m_pNormalWidget)->EditPaste(wsPaste); | 440 ((CFWL_ComboBox*)m_pNormalWidget)->EditPaste(wsPaste); |
443 } | 441 } |
444 FX_BOOL CXFA_FFComboBox::SelectAll() { | 442 bool CXFA_FFComboBox::SelectAll() { |
445 return ((CFWL_ComboBox*)m_pNormalWidget)->EditSelectAll(); | 443 return ((CFWL_ComboBox*)m_pNormalWidget)->EditSelectAll(); |
446 } | 444 } |
447 FX_BOOL CXFA_FFComboBox::Delete() { | 445 bool CXFA_FFComboBox::Delete() { |
448 return ((CFWL_ComboBox*)m_pNormalWidget)->EditDelete(); | 446 return ((CFWL_ComboBox*)m_pNormalWidget)->EditDelete(); |
449 } | 447 } |
450 FX_BOOL CXFA_FFComboBox::DeSelect() { | 448 bool CXFA_FFComboBox::DeSelect() { |
451 return ((CFWL_ComboBox*)m_pNormalWidget)->EditDeSelect(); | 449 return ((CFWL_ComboBox*)m_pNormalWidget)->EditDeSelect(); |
452 } | 450 } |
453 void CXFA_FFComboBox::SetItemState(int32_t nIndex, FX_BOOL bSelected) { | 451 void CXFA_FFComboBox::SetItemState(int32_t nIndex, bool bSelected) { |
454 if (bSelected) { | 452 if (bSelected) { |
455 ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(nIndex); | 453 ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(nIndex); |
456 } else { | 454 } else { |
457 ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(-1); | 455 ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(-1); |
458 } | 456 } |
459 m_pNormalWidget->Update(); | 457 m_pNormalWidget->Update(); |
460 AddInvalidateRect(); | 458 AddInvalidateRect(); |
461 } | 459 } |
462 void CXFA_FFComboBox::InsertItem(const CFX_WideStringC& wsLabel, | 460 void CXFA_FFComboBox::InsertItem(const CFX_WideStringC& wsLabel, |
463 int32_t nIndex) { | 461 int32_t nIndex) { |
(...skipping 12 matching lines...) Expand all Loading... |
476 } | 474 } |
477 void CXFA_FFComboBox::OnTextChanged(IFWL_Widget* pWidget, | 475 void CXFA_FFComboBox::OnTextChanged(IFWL_Widget* pWidget, |
478 const CFX_WideString& wsChanged) { | 476 const CFX_WideString& wsChanged) { |
479 CXFA_EventParam eParam; | 477 CXFA_EventParam eParam; |
480 m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); | 478 m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); |
481 eParam.m_wsChange = wsChanged; | 479 eParam.m_wsChange = wsChanged; |
482 FWLEventSelChange(&eParam); | 480 FWLEventSelChange(&eParam); |
483 } | 481 } |
484 void CXFA_FFComboBox::OnSelectChanged(IFWL_Widget* pWidget, | 482 void CXFA_FFComboBox::OnSelectChanged(IFWL_Widget* pWidget, |
485 const CFX_Int32Array& arrSels, | 483 const CFX_Int32Array& arrSels, |
486 FX_BOOL bLButtonUp) { | 484 bool bLButtonUp) { |
487 CXFA_EventParam eParam; | 485 CXFA_EventParam eParam; |
488 m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); | 486 m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); |
489 FWLEventSelChange(&eParam); | 487 FWLEventSelChange(&eParam); |
490 if (m_pDataAcc->GetChoiceListCommitOn() == XFA_ATTRIBUTEENUM_Select && | 488 if (m_pDataAcc->GetChoiceListCommitOn() == XFA_ATTRIBUTEENUM_Select && |
491 bLButtonUp) { | 489 bLButtonUp) { |
492 m_pDocView->SetFocusWidgetAcc(nullptr); | 490 m_pDocView->SetFocusWidgetAcc(nullptr); |
493 } | 491 } |
494 } | 492 } |
495 void CXFA_FFComboBox::OnPreOpen(IFWL_Widget* pWidget) { | 493 void CXFA_FFComboBox::OnPreOpen(IFWL_Widget* pWidget) { |
496 CXFA_EventParam eParam; | 494 CXFA_EventParam eParam; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 default: | 532 default: |
535 break; | 533 break; |
536 } | 534 } |
537 m_pOldDelegate->OnProcessEvent(pEvent); | 535 m_pOldDelegate->OnProcessEvent(pEvent); |
538 } | 536 } |
539 | 537 |
540 void CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics, | 538 void CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics, |
541 const CFX_Matrix* pMatrix) { | 539 const CFX_Matrix* pMatrix) { |
542 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); | 540 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); |
543 } | 541 } |
OLD | NEW |