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_fftextedit.h" | 7 #include "xfa/fxfa/app/xfa_fftextedit.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(nullptr) {} | 29 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(nullptr) {} |
30 | 30 |
31 CXFA_FFTextEdit::~CXFA_FFTextEdit() { | 31 CXFA_FFTextEdit::~CXFA_FFTextEdit() { |
32 if (m_pNormalWidget) { | 32 if (m_pNormalWidget) { |
33 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); | 33 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); |
34 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); | 34 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); |
35 pNoteDriver->UnregisterEventTarget(pWidget); | 35 pNoteDriver->UnregisterEventTarget(pWidget); |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 FX_BOOL CXFA_FFTextEdit::LoadWidget() { | 39 bool CXFA_FFTextEdit::LoadWidget() { |
40 CFWL_Edit* pFWLEdit = new CFWL_Edit(GetFWLApp()); | 40 CFWL_Edit* pFWLEdit = new CFWL_Edit(GetFWLApp()); |
41 pFWLEdit->Initialize(); | 41 pFWLEdit->Initialize(); |
42 m_pNormalWidget = pFWLEdit; | 42 m_pNormalWidget = pFWLEdit; |
43 m_pNormalWidget->SetLayoutItem(this); | 43 m_pNormalWidget->SetLayoutItem(this); |
44 | 44 |
45 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); | 45 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); |
46 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); | 46 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); |
47 pNoteDriver->RegisterEventTarget(pWidget, pWidget); | 47 pNoteDriver->RegisterEventTarget(pWidget, pWidget); |
48 | 48 |
49 m_pOldDelegate = m_pNormalWidget->GetDelegate(); | 49 m_pOldDelegate = m_pNormalWidget->GetDelegate(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } else if (iNumCells > 0) { | 93 } else if (iNumCells > 0) { |
94 dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; | 94 dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; |
95 pWidget->SetLimit(iNumCells); | 95 pWidget->SetLimit(iNumCells); |
96 } else { | 96 } else { |
97 pWidget->SetLimit(iMaxChars); | 97 pWidget->SetLimit(iMaxChars); |
98 } | 98 } |
99 dwExtendedStyle |= GetAlignment(); | 99 dwExtendedStyle |= GetAlignment(); |
100 m_pNormalWidget->ModifyStyles(dwStyle, 0xFFFFFFFF); | 100 m_pNormalWidget->ModifyStyles(dwStyle, 0xFFFFFFFF); |
101 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); | 101 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); |
102 } | 102 } |
103 FX_BOOL CXFA_FFTextEdit::OnLButtonDown(uint32_t dwFlags, | 103 bool CXFA_FFTextEdit::OnLButtonDown(uint32_t dwFlags, |
104 FX_FLOAT fx, | 104 FX_FLOAT fx, |
105 FX_FLOAT fy) { | 105 FX_FLOAT fy) { |
106 if (!PtInActiveRect(fx, fy)) { | 106 if (!PtInActiveRect(fx, fy)) { |
107 return FALSE; | 107 return false; |
108 } | 108 } |
109 if (!IsFocused()) { | 109 if (!IsFocused()) { |
110 m_dwStatus |= XFA_WidgetStatus_Focused; | 110 m_dwStatus |= XFA_WidgetStatus_Focused; |
111 UpdateFWLData(); | 111 UpdateFWLData(); |
112 AddInvalidateRect(); | 112 AddInvalidateRect(); |
113 } | 113 } |
114 SetButtonDown(TRUE); | 114 SetButtonDown(true); |
115 CFWL_MsgMouse ms; | 115 CFWL_MsgMouse ms; |
116 ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; | 116 ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; |
117 ms.m_dwFlags = dwFlags; | 117 ms.m_dwFlags = dwFlags; |
118 ms.m_fx = fx; | 118 ms.m_fx = fx; |
119 ms.m_fy = fy; | 119 ms.m_fy = fy; |
120 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); | 120 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); |
121 FWLToClient(ms.m_fx, ms.m_fy); | 121 FWLToClient(ms.m_fx, ms.m_fy); |
122 TranslateFWLMessage(&ms); | 122 TranslateFWLMessage(&ms); |
123 return TRUE; | 123 return true; |
124 } | 124 } |
125 FX_BOOL CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags, | 125 bool CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags, |
126 FX_FLOAT fx, | 126 FX_FLOAT fx, |
127 FX_FLOAT fy) { | 127 FX_FLOAT fy) { |
128 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { | 128 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { |
129 return FALSE; | 129 return false; |
130 } | 130 } |
131 if (!PtInActiveRect(fx, fy)) { | 131 if (!PtInActiveRect(fx, fy)) { |
132 return FALSE; | 132 return false; |
133 } | 133 } |
134 if (!IsFocused()) { | 134 if (!IsFocused()) { |
135 m_dwStatus |= XFA_WidgetStatus_Focused; | 135 m_dwStatus |= XFA_WidgetStatus_Focused; |
136 UpdateFWLData(); | 136 UpdateFWLData(); |
137 AddInvalidateRect(); | 137 AddInvalidateRect(); |
138 } | 138 } |
139 SetButtonDown(TRUE); | 139 SetButtonDown(true); |
140 CFWL_MsgMouse ms; | 140 CFWL_MsgMouse ms; |
141 ms.m_dwCmd = FWL_MouseCommand::RightButtonDown; | 141 ms.m_dwCmd = FWL_MouseCommand::RightButtonDown; |
142 ms.m_dwFlags = dwFlags; | 142 ms.m_dwFlags = dwFlags; |
143 ms.m_fx = fx; | 143 ms.m_fx = fx; |
144 ms.m_fy = fy; | 144 ms.m_fy = fy; |
145 FWLToClient(ms.m_fx, ms.m_fy); | 145 FWLToClient(ms.m_fx, ms.m_fy); |
146 TranslateFWLMessage(&ms); | 146 TranslateFWLMessage(&ms); |
147 return TRUE; | 147 return true; |
148 } | 148 } |
149 FX_BOOL CXFA_FFTextEdit::OnRButtonUp(uint32_t dwFlags, | 149 bool CXFA_FFTextEdit::OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { |
150 FX_FLOAT fx, | |
151 FX_FLOAT fy) { | |
152 if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) | 150 if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) |
153 return FALSE; | 151 return false; |
154 | 152 |
155 GetDoc()->GetDocEnvironment()->PopupMenu(this, CFX_PointF(fx, fy)); | 153 GetDoc()->GetDocEnvironment()->PopupMenu(this, CFX_PointF(fx, fy)); |
156 return TRUE; | 154 return true; |
157 } | 155 } |
158 FX_BOOL CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) { | 156 bool CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) { |
159 m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; | 157 m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; |
160 if (!IsFocused()) { | 158 if (!IsFocused()) { |
161 m_dwStatus |= XFA_WidgetStatus_Focused; | 159 m_dwStatus |= XFA_WidgetStatus_Focused; |
162 UpdateFWLData(); | 160 UpdateFWLData(); |
163 AddInvalidateRect(); | 161 AddInvalidateRect(); |
164 } | 162 } |
165 CXFA_FFWidget::OnSetFocus(pOldWidget); | 163 CXFA_FFWidget::OnSetFocus(pOldWidget); |
166 CFWL_MsgSetFocus ms; | 164 CFWL_MsgSetFocus ms; |
167 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); | 165 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); |
168 ms.m_pSrcTarget = nullptr; | 166 ms.m_pSrcTarget = nullptr; |
169 TranslateFWLMessage(&ms); | 167 TranslateFWLMessage(&ms); |
170 return TRUE; | 168 return true; |
171 } | 169 } |
172 FX_BOOL CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) { | 170 bool CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) { |
173 CFWL_MsgKillFocus ms; | 171 CFWL_MsgKillFocus ms; |
174 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); | 172 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); |
175 ms.m_pSrcTarget = nullptr; | 173 ms.m_pSrcTarget = nullptr; |
176 TranslateFWLMessage(&ms); | 174 TranslateFWLMessage(&ms); |
177 m_dwStatus &= ~XFA_WidgetStatus_Focused; | 175 m_dwStatus &= ~XFA_WidgetStatus_Focused; |
178 SetEditScrollOffset(); | 176 SetEditScrollOffset(); |
179 ProcessCommittedData(); | 177 ProcessCommittedData(); |
180 UpdateFWLData(); | 178 UpdateFWLData(); |
181 AddInvalidateRect(); | 179 AddInvalidateRect(); |
182 CXFA_FFWidget::OnKillFocus(pNewWidget); | 180 CXFA_FFWidget::OnKillFocus(pNewWidget); |
183 m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; | 181 m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; |
184 return TRUE; | 182 return true; |
185 } | 183 } |
186 FX_BOOL CXFA_FFTextEdit::CommitData() { | 184 bool CXFA_FFTextEdit::CommitData() { |
187 CFX_WideString wsText; | 185 CFX_WideString wsText; |
188 ((CFWL_Edit*)m_pNormalWidget)->GetText(wsText); | 186 ((CFWL_Edit*)m_pNormalWidget)->GetText(wsText); |
189 if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) { | 187 if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) { |
190 m_pDataAcc->UpdateUIDisplay(this); | 188 m_pDataAcc->UpdateUIDisplay(this); |
191 return TRUE; | 189 return true; |
192 } | 190 } |
193 ValidateNumberField(wsText); | 191 ValidateNumberField(wsText); |
194 return FALSE; | 192 return false; |
195 } | 193 } |
196 void CXFA_FFTextEdit::ValidateNumberField(const CFX_WideString& wsText) { | 194 void CXFA_FFTextEdit::ValidateNumberField(const CFX_WideString& wsText) { |
197 CXFA_WidgetAcc* pAcc = GetDataAcc(); | 195 CXFA_WidgetAcc* pAcc = GetDataAcc(); |
198 if (pAcc && pAcc->GetUIType() == XFA_Element::NumericEdit) { | 196 if (pAcc && pAcc->GetUIType() == XFA_Element::NumericEdit) { |
199 IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); | 197 IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); |
200 if (pAppProvider) { | 198 if (pAppProvider) { |
201 CFX_WideString wsTitle; | 199 CFX_WideString wsTitle; |
202 pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); | 200 pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); |
203 CFX_WideString wsError; | 201 CFX_WideString wsError; |
204 pAppProvider->LoadString(XFA_IDS_ValidateNumberError, wsError); | 202 pAppProvider->LoadString(XFA_IDS_ValidateNumberError, wsError); |
205 CFX_WideString wsSomField; | 203 CFX_WideString wsSomField; |
206 pAcc->GetNode()->GetSOMExpression(wsSomField); | 204 pAcc->GetNode()->GetSOMExpression(wsSomField); |
207 CFX_WideString wsMessage; | 205 CFX_WideString wsMessage; |
208 wsMessage.Format(wsError.c_str(), wsText.c_str(), wsSomField.c_str()); | 206 wsMessage.Format(wsError.c_str(), wsText.c_str(), wsSomField.c_str()); |
209 pAppProvider->MsgBox(wsMessage, wsTitle, XFA_MBICON_Error, XFA_MB_OK); | 207 pAppProvider->MsgBox(wsMessage, wsTitle, XFA_MBICON_Error, XFA_MB_OK); |
210 } | 208 } |
211 } | 209 } |
212 } | 210 } |
213 FX_BOOL CXFA_FFTextEdit::IsDataChanged() { | 211 bool CXFA_FFTextEdit::IsDataChanged() { |
214 return (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) != 0; | 212 return (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) != 0; |
215 } | 213 } |
216 uint32_t CXFA_FFTextEdit::GetAlignment() { | 214 uint32_t CXFA_FFTextEdit::GetAlignment() { |
217 uint32_t dwExtendedStyle = 0; | 215 uint32_t dwExtendedStyle = 0; |
218 if (CXFA_Para para = m_pDataAcc->GetPara()) { | 216 if (CXFA_Para para = m_pDataAcc->GetPara()) { |
219 int32_t iHorz = para.GetHorizontalAlign(); | 217 int32_t iHorz = para.GetHorizontalAlign(); |
220 switch (iHorz) { | 218 switch (iHorz) { |
221 case XFA_ATTRIBUTEENUM_Center: | 219 case XFA_ATTRIBUTEENUM_Center: |
222 dwExtendedStyle |= FWL_STYLEEXT_EDT_HCenter; | 220 dwExtendedStyle |= FWL_STYLEEXT_EDT_HCenter; |
223 break; | 221 break; |
(...skipping 19 matching lines...) Expand all Loading... |
243 case XFA_ATTRIBUTEENUM_Bottom: | 241 case XFA_ATTRIBUTEENUM_Bottom: |
244 dwExtendedStyle |= FWL_STYLEEXT_EDT_VFar; | 242 dwExtendedStyle |= FWL_STYLEEXT_EDT_VFar; |
245 break; | 243 break; |
246 default: | 244 default: |
247 dwExtendedStyle |= FWL_STYLEEXT_EDT_VNear; | 245 dwExtendedStyle |= FWL_STYLEEXT_EDT_VNear; |
248 break; | 246 break; |
249 } | 247 } |
250 } | 248 } |
251 return dwExtendedStyle; | 249 return dwExtendedStyle; |
252 } | 250 } |
253 FX_BOOL CXFA_FFTextEdit::UpdateFWLData() { | 251 bool CXFA_FFTextEdit::UpdateFWLData() { |
254 if (!m_pNormalWidget) { | 252 if (!m_pNormalWidget) { |
255 return FALSE; | 253 return false; |
256 } | 254 } |
257 XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; | 255 XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; |
258 if (IsFocused()) { | 256 if (IsFocused()) { |
259 eType = XFA_VALUEPICTURE_Edit; | 257 eType = XFA_VALUEPICTURE_Edit; |
260 } | 258 } |
261 FX_BOOL bUpdate = FALSE; | 259 bool bUpdate = false; |
262 if (m_pDataAcc->GetUIType() == XFA_Element::TextEdit && | 260 if (m_pDataAcc->GetUIType() == XFA_Element::TextEdit && |
263 m_pDataAcc->GetNumberOfCells() < 0) { | 261 m_pDataAcc->GetNumberOfCells() < 0) { |
264 XFA_Element elementType = XFA_Element::Unknown; | 262 XFA_Element elementType = XFA_Element::Unknown; |
265 int32_t iMaxChars = m_pDataAcc->GetMaxChars(elementType); | 263 int32_t iMaxChars = m_pDataAcc->GetMaxChars(elementType); |
266 if (elementType == XFA_Element::ExData) { | 264 if (elementType == XFA_Element::ExData) { |
267 iMaxChars = eType == XFA_VALUEPICTURE_Edit ? iMaxChars : 0; | 265 iMaxChars = eType == XFA_VALUEPICTURE_Edit ? iMaxChars : 0; |
268 } | 266 } |
269 if (((CFWL_Edit*)m_pNormalWidget)->GetLimit() != iMaxChars) { | 267 if (((CFWL_Edit*)m_pNormalWidget)->GetLimit() != iMaxChars) { |
270 ((CFWL_Edit*)m_pNormalWidget)->SetLimit(iMaxChars); | 268 ((CFWL_Edit*)m_pNormalWidget)->SetLimit(iMaxChars); |
271 bUpdate = TRUE; | 269 bUpdate = true; |
272 } | 270 } |
273 } | 271 } |
274 if (m_pDataAcc->GetUIType() == XFA_Element::Barcode) { | 272 if (m_pDataAcc->GetUIType() == XFA_Element::Barcode) { |
275 int32_t nDataLen = 0; | 273 int32_t nDataLen = 0; |
276 if (eType == XFA_VALUEPICTURE_Edit) | 274 if (eType == XFA_VALUEPICTURE_Edit) |
277 m_pDataAcc->GetBarcodeAttribute_DataLength(nDataLen); | 275 m_pDataAcc->GetBarcodeAttribute_DataLength(nDataLen); |
278 static_cast<CFWL_Edit*>(m_pNormalWidget)->SetLimit(nDataLen); | 276 static_cast<CFWL_Edit*>(m_pNormalWidget)->SetLimit(nDataLen); |
279 bUpdate = TRUE; | 277 bUpdate = true; |
280 } | 278 } |
281 CFX_WideString wsText; | 279 CFX_WideString wsText; |
282 m_pDataAcc->GetValue(wsText, eType); | 280 m_pDataAcc->GetValue(wsText, eType); |
283 CFX_WideString wsOldText; | 281 CFX_WideString wsOldText; |
284 ((CFWL_Edit*)m_pNormalWidget)->GetText(wsOldText); | 282 ((CFWL_Edit*)m_pNormalWidget)->GetText(wsOldText); |
285 if (wsText != wsOldText || (eType == XFA_VALUEPICTURE_Edit && bUpdate)) { | 283 if (wsText != wsOldText || (eType == XFA_VALUEPICTURE_Edit && bUpdate)) { |
286 ((CFWL_Edit*)m_pNormalWidget)->SetText(wsText); | 284 ((CFWL_Edit*)m_pNormalWidget)->SetText(wsText); |
287 bUpdate = TRUE; | 285 bUpdate = true; |
288 } | 286 } |
289 if (bUpdate) { | 287 if (bUpdate) { |
290 m_pNormalWidget->Update(); | 288 m_pNormalWidget->Update(); |
291 } | 289 } |
292 return TRUE; | 290 return true; |
293 } | 291 } |
294 FX_BOOL CXFA_FFTextEdit::CanUndo() { | 292 bool CXFA_FFTextEdit::CanUndo() { |
295 return ((CFWL_Edit*)m_pNormalWidget)->CanUndo(); | 293 return ((CFWL_Edit*)m_pNormalWidget)->CanUndo(); |
296 } | 294 } |
297 FX_BOOL CXFA_FFTextEdit::CanRedo() { | 295 bool CXFA_FFTextEdit::CanRedo() { |
298 return ((CFWL_Edit*)m_pNormalWidget)->CanRedo(); | 296 return ((CFWL_Edit*)m_pNormalWidget)->CanRedo(); |
299 } | 297 } |
300 FX_BOOL CXFA_FFTextEdit::Undo() { | 298 bool CXFA_FFTextEdit::Undo() { |
301 return ((CFWL_Edit*)m_pNormalWidget)->Undo(); | 299 return ((CFWL_Edit*)m_pNormalWidget)->Undo(); |
302 } | 300 } |
303 FX_BOOL CXFA_FFTextEdit::Redo() { | 301 bool CXFA_FFTextEdit::Redo() { |
304 return ((CFWL_Edit*)m_pNormalWidget)->Redo(); | 302 return ((CFWL_Edit*)m_pNormalWidget)->Redo(); |
305 } | 303 } |
306 FX_BOOL CXFA_FFTextEdit::CanCopy() { | 304 bool CXFA_FFTextEdit::CanCopy() { |
307 int32_t nCount = ((CFWL_Edit*)m_pNormalWidget)->CountSelRanges(); | 305 int32_t nCount = ((CFWL_Edit*)m_pNormalWidget)->CountSelRanges(); |
308 return nCount > 0; | 306 return nCount > 0; |
309 } | 307 } |
310 FX_BOOL CXFA_FFTextEdit::CanCut() { | 308 bool CXFA_FFTextEdit::CanCut() { |
311 if (m_pNormalWidget->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) { | 309 if (m_pNormalWidget->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) { |
312 return FALSE; | 310 return false; |
313 } | 311 } |
314 int32_t nCount = ((CFWL_Edit*)m_pNormalWidget)->CountSelRanges(); | 312 int32_t nCount = ((CFWL_Edit*)m_pNormalWidget)->CountSelRanges(); |
315 return nCount > 0; | 313 return nCount > 0; |
316 } | 314 } |
317 FX_BOOL CXFA_FFTextEdit::CanPaste() { | 315 bool CXFA_FFTextEdit::CanPaste() { |
318 return m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open; | 316 return m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open; |
319 } | 317 } |
320 FX_BOOL CXFA_FFTextEdit::CanSelectAll() { | 318 bool CXFA_FFTextEdit::CanSelectAll() { |
321 return ((CFWL_Edit*)m_pNormalWidget)->GetTextLength() > 0; | 319 return ((CFWL_Edit*)m_pNormalWidget)->GetTextLength() > 0; |
322 } | 320 } |
323 FX_BOOL CXFA_FFTextEdit::Copy(CFX_WideString& wsCopy) { | 321 bool CXFA_FFTextEdit::Copy(CFX_WideString& wsCopy) { |
324 return ((CFWL_Edit*)m_pNormalWidget)->Copy(wsCopy); | 322 return ((CFWL_Edit*)m_pNormalWidget)->Copy(wsCopy); |
325 } | 323 } |
326 FX_BOOL CXFA_FFTextEdit::Cut(CFX_WideString& wsCut) { | 324 bool CXFA_FFTextEdit::Cut(CFX_WideString& wsCut) { |
327 return ((CFWL_Edit*)m_pNormalWidget)->Cut(wsCut); | 325 return ((CFWL_Edit*)m_pNormalWidget)->Cut(wsCut); |
328 } | 326 } |
329 FX_BOOL CXFA_FFTextEdit::Paste(const CFX_WideString& wsPaste) { | 327 bool CXFA_FFTextEdit::Paste(const CFX_WideString& wsPaste) { |
330 return ((CFWL_Edit*)m_pNormalWidget)->Paste(wsPaste); | 328 return ((CFWL_Edit*)m_pNormalWidget)->Paste(wsPaste); |
331 } | 329 } |
332 FX_BOOL CXFA_FFTextEdit::SelectAll() { | 330 bool CXFA_FFTextEdit::SelectAll() { |
333 int32_t nCount = ((CFWL_Edit*)m_pNormalWidget)->GetTextLength(); | 331 int32_t nCount = ((CFWL_Edit*)m_pNormalWidget)->GetTextLength(); |
334 return ((CFWL_Edit*)m_pNormalWidget)->AddSelRange(0, nCount) >= 0; | 332 return ((CFWL_Edit*)m_pNormalWidget)->AddSelRange(0, nCount) >= 0; |
335 } | 333 } |
336 FX_BOOL CXFA_FFTextEdit::Delete() { | 334 bool CXFA_FFTextEdit::Delete() { |
337 return ((CFWL_Edit*)m_pNormalWidget)->Delete(); | 335 return ((CFWL_Edit*)m_pNormalWidget)->Delete(); |
338 } | 336 } |
339 FX_BOOL CXFA_FFTextEdit::DeSelect() { | 337 bool CXFA_FFTextEdit::DeSelect() { |
340 return ((CFWL_Edit*)m_pNormalWidget)->ClearSelections() == | 338 return ((CFWL_Edit*)m_pNormalWidget)->ClearSelections() == |
341 FWL_Error::Succeeded; | 339 FWL_Error::Succeeded; |
342 } | 340 } |
343 FX_BOOL CXFA_FFTextEdit::GetSuggestWords( | 341 bool CXFA_FFTextEdit::GetSuggestWords(CFX_PointF pointf, |
344 CFX_PointF pointf, | 342 std::vector<CFX_ByteString>& sSuggest) { |
345 std::vector<CFX_ByteString>& sSuggest) { | |
346 if (m_pDataAcc->GetUIType() != XFA_Element::TextEdit) { | 343 if (m_pDataAcc->GetUIType() != XFA_Element::TextEdit) { |
347 return FALSE; | 344 return false; |
348 } | 345 } |
349 FWLToClient(pointf.x, pointf.y); | 346 FWLToClient(pointf.x, pointf.y); |
350 return ((CFWL_Edit*)m_pNormalWidget)->GetSuggestWords(pointf, sSuggest); | 347 return ((CFWL_Edit*)m_pNormalWidget)->GetSuggestWords(pointf, sSuggest); |
351 } | 348 } |
352 FX_BOOL CXFA_FFTextEdit::ReplaceSpellCheckWord( | 349 bool CXFA_FFTextEdit::ReplaceSpellCheckWord(CFX_PointF pointf, |
353 CFX_PointF pointf, | 350 const CFX_ByteStringC& bsReplace) { |
354 const CFX_ByteStringC& bsReplace) { | |
355 if (m_pDataAcc->GetUIType() != XFA_Element::TextEdit) { | 351 if (m_pDataAcc->GetUIType() != XFA_Element::TextEdit) { |
356 return FALSE; | 352 return false; |
357 } | 353 } |
358 FWLToClient(pointf.x, pointf.y); | 354 FWLToClient(pointf.x, pointf.y); |
359 return ((CFWL_Edit*)m_pNormalWidget) | 355 return ((CFWL_Edit*)m_pNormalWidget) |
360 ->ReplaceSpellCheckWord(pointf, bsReplace); | 356 ->ReplaceSpellCheckWord(pointf, bsReplace); |
361 } | 357 } |
362 void CXFA_FFTextEdit::OnTextChanged(IFWL_Widget* pWidget, | 358 void CXFA_FFTextEdit::OnTextChanged(IFWL_Widget* pWidget, |
363 const CFX_WideString& wsChanged, | 359 const CFX_WideString& wsChanged, |
364 const CFX_WideString& wsPrevText) { | 360 const CFX_WideString& wsPrevText) { |
365 m_dwStatus |= XFA_WidgetStatus_TextEditValueChanged; | 361 m_dwStatus |= XFA_WidgetStatus_TextEditValueChanged; |
366 CXFA_EventParam eParam; | 362 CXFA_EventParam eParam; |
(...skipping 18 matching lines...) Expand all Loading... |
385 } | 381 } |
386 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); | 382 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); |
387 } | 383 } |
388 void CXFA_FFTextEdit::OnTextFull(IFWL_Widget* pWidget) { | 384 void CXFA_FFTextEdit::OnTextFull(IFWL_Widget* pWidget) { |
389 CXFA_EventParam eParam; | 385 CXFA_EventParam eParam; |
390 eParam.m_eType = XFA_EVENT_Full; | 386 eParam.m_eType = XFA_EVENT_Full; |
391 eParam.m_pTarget = m_pDataAcc; | 387 eParam.m_pTarget = m_pDataAcc; |
392 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Full, &eParam); | 388 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Full, &eParam); |
393 } | 389 } |
394 | 390 |
395 FX_BOOL CXFA_FFTextEdit::CheckWord(const CFX_ByteStringC& sWord) { | 391 bool CXFA_FFTextEdit::CheckWord(const CFX_ByteStringC& sWord) { |
396 if (sWord.IsEmpty() || m_pDataAcc->GetUIType() != XFA_Element::TextEdit) | 392 if (sWord.IsEmpty() || m_pDataAcc->GetUIType() != XFA_Element::TextEdit) |
397 return TRUE; | 393 return true; |
398 return FALSE; | 394 return false; |
399 } | 395 } |
400 | 396 |
401 void CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { | 397 void CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { |
402 m_pOldDelegate->OnProcessMessage(pMessage); | 398 m_pOldDelegate->OnProcessMessage(pMessage); |
403 } | 399 } |
404 | 400 |
405 void CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { | 401 void CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { |
406 CXFA_FFField::OnProcessEvent(pEvent); | 402 CXFA_FFField::OnProcessEvent(pEvent); |
407 switch (pEvent->GetClassID()) { | 403 switch (pEvent->GetClassID()) { |
408 case CFWL_EventType::TextChanged: { | 404 case CFWL_EventType::TextChanged: { |
409 CFWL_EvtEdtTextChanged* event = (CFWL_EvtEdtTextChanged*)pEvent; | 405 CFWL_EvtEdtTextChanged* event = (CFWL_EvtEdtTextChanged*)pEvent; |
410 CFX_WideString wsChange; | 406 CFX_WideString wsChange; |
411 OnTextChanged(m_pNormalWidget->GetWidget(), wsChange, event->wsPrevText); | 407 OnTextChanged(m_pNormalWidget->GetWidget(), wsChange, event->wsPrevText); |
412 break; | 408 break; |
413 } | 409 } |
414 case CFWL_EventType::TextFull: { | 410 case CFWL_EventType::TextFull: { |
415 OnTextFull(m_pNormalWidget->GetWidget()); | 411 OnTextFull(m_pNormalWidget->GetWidget()); |
416 break; | 412 break; |
417 } | 413 } |
418 case CFWL_EventType::CheckWord: { | 414 case CFWL_EventType::CheckWord: { |
419 CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); | 415 CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); |
420 CFWL_EvtEdtCheckWord* event = (CFWL_EvtEdtCheckWord*)pEvent; | 416 CFWL_EvtEdtCheckWord* event = (CFWL_EvtEdtCheckWord*)pEvent; |
421 event->bCheckWord = CheckWord(event->bsWord.AsStringC()); | 417 event->bCheckWord = CheckWord(event->bsWord.AsStringC()); |
422 break; | 418 break; |
423 } | 419 } |
424 case CFWL_EventType::GetSuggestedWords: { | 420 case CFWL_EventType::GetSuggestedWords: { |
425 CFWL_EvtEdtGetSuggestWords* event = (CFWL_EvtEdtGetSuggestWords*)pEvent; | 421 CFWL_EvtEdtGetSuggestWords* event = (CFWL_EvtEdtGetSuggestWords*)pEvent; |
426 event->bSuggestWords = FALSE; | 422 event->bSuggestWords = false; |
427 break; | 423 break; |
428 } | 424 } |
429 default: | 425 default: |
430 break; | 426 break; |
431 } | 427 } |
432 m_pOldDelegate->OnProcessEvent(pEvent); | 428 m_pOldDelegate->OnProcessEvent(pEvent); |
433 } | 429 } |
434 | 430 |
435 void CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, | 431 void CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, |
436 const CFX_Matrix* pMatrix) { | 432 const CFX_Matrix* pMatrix) { |
437 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); | 433 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); |
438 } | 434 } |
439 | 435 |
440 CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_FFPageView* pPageView, | 436 CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_FFPageView* pPageView, |
441 CXFA_WidgetAcc* pDataAcc) | 437 CXFA_WidgetAcc* pDataAcc) |
442 : CXFA_FFTextEdit(pPageView, pDataAcc) {} | 438 : CXFA_FFTextEdit(pPageView, pDataAcc) {} |
443 CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} | 439 CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} |
444 FX_BOOL CXFA_FFNumericEdit::LoadWidget() { | 440 bool CXFA_FFNumericEdit::LoadWidget() { |
445 CFWL_Edit* pWidget = new CFWL_Edit(GetFWLApp()); | 441 CFWL_Edit* pWidget = new CFWL_Edit(GetFWLApp()); |
446 pWidget->Initialize(); | 442 pWidget->Initialize(); |
447 m_pNormalWidget = pWidget; | 443 m_pNormalWidget = pWidget; |
448 | 444 |
449 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); | 445 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); |
450 m_pNormalWidget->SetLayoutItem(this); | 446 m_pNormalWidget->SetLayoutItem(this); |
451 CFWL_NoteDriver* pNoteDriver = pIWidget->GetOwnerApp()->GetNoteDriver(); | 447 CFWL_NoteDriver* pNoteDriver = pIWidget->GetOwnerApp()->GetNoteDriver(); |
452 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); | 448 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); |
453 | 449 |
454 m_pOldDelegate = m_pNormalWidget->GetDelegate(); | 450 m_pOldDelegate = m_pNormalWidget->GetDelegate(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 void CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { | 487 void CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { |
492 if (pEvent->GetClassID() == CFWL_EventType::Validate) { | 488 if (pEvent->GetClassID() == CFWL_EventType::Validate) { |
493 CFWL_EvtEdtValidate* event = (CFWL_EvtEdtValidate*)pEvent; | 489 CFWL_EvtEdtValidate* event = (CFWL_EvtEdtValidate*)pEvent; |
494 CFX_WideString wsChange = event->wsInsert; | 490 CFX_WideString wsChange = event->wsInsert; |
495 event->bValidate = OnValidate(m_pNormalWidget->GetWidget(), wsChange); | 491 event->bValidate = OnValidate(m_pNormalWidget->GetWidget(), wsChange); |
496 return; | 492 return; |
497 } | 493 } |
498 CXFA_FFTextEdit::OnProcessEvent(pEvent); | 494 CXFA_FFTextEdit::OnProcessEvent(pEvent); |
499 } | 495 } |
500 | 496 |
501 FX_BOOL CXFA_FFNumericEdit::OnValidate(IFWL_Widget* pWidget, | 497 bool CXFA_FFNumericEdit::OnValidate(IFWL_Widget* pWidget, |
502 CFX_WideString& wsText) { | 498 CFX_WideString& wsText) { |
503 CFX_WideString wsPattern; | 499 CFX_WideString wsPattern; |
504 m_pDataAcc->GetPictureContent(wsPattern, XFA_VALUEPICTURE_Edit); | 500 m_pDataAcc->GetPictureContent(wsPattern, XFA_VALUEPICTURE_Edit); |
505 if (!wsPattern.IsEmpty()) { | 501 if (!wsPattern.IsEmpty()) { |
506 return TRUE; | 502 return true; |
507 } | 503 } |
508 int32_t iLeads = 0; | 504 int32_t iLeads = 0; |
509 m_pDataAcc->GetLeadDigits(iLeads); | 505 m_pDataAcc->GetLeadDigits(iLeads); |
510 int32_t iFracs = 0; | 506 int32_t iFracs = 0; |
511 m_pDataAcc->GetFracDigits(iFracs); | 507 m_pDataAcc->GetFracDigits(iFracs); |
512 CFX_WideString wsFormat; | 508 CFX_WideString wsFormat; |
513 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(m_pDataAcc); | 509 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(m_pDataAcc); |
514 widgetValue.GetNumbericFormat(wsFormat, iLeads, iFracs); | 510 widgetValue.GetNumbericFormat(wsFormat, iLeads, iFracs); |
515 return widgetValue.ValidateNumericTemp(wsText, wsFormat, | 511 return widgetValue.ValidateNumericTemp(wsText, wsFormat, |
516 m_pDataAcc->GetLocal()); | 512 m_pDataAcc->GetLocal()); |
517 } | 513 } |
518 CXFA_FFPasswordEdit::CXFA_FFPasswordEdit(CXFA_FFPageView* pPageView, | 514 CXFA_FFPasswordEdit::CXFA_FFPasswordEdit(CXFA_FFPageView* pPageView, |
519 CXFA_WidgetAcc* pDataAcc) | 515 CXFA_WidgetAcc* pDataAcc) |
520 : CXFA_FFTextEdit(pPageView, pDataAcc) {} | 516 : CXFA_FFTextEdit(pPageView, pDataAcc) {} |
521 | 517 |
522 CXFA_FFPasswordEdit::~CXFA_FFPasswordEdit() {} | 518 CXFA_FFPasswordEdit::~CXFA_FFPasswordEdit() {} |
523 | 519 |
524 FX_BOOL CXFA_FFPasswordEdit::LoadWidget() { | 520 bool CXFA_FFPasswordEdit::LoadWidget() { |
525 CFWL_Edit* pWidget = new CFWL_Edit(GetFWLApp()); | 521 CFWL_Edit* pWidget = new CFWL_Edit(GetFWLApp()); |
526 pWidget->Initialize(); | 522 pWidget->Initialize(); |
527 m_pNormalWidget = pWidget; | 523 m_pNormalWidget = pWidget; |
528 m_pNormalWidget->SetLayoutItem(this); | 524 m_pNormalWidget->SetLayoutItem(this); |
529 | 525 |
530 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); | 526 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); |
531 CFWL_NoteDriver* pNoteDriver = pIWidget->GetOwnerApp()->GetNoteDriver(); | 527 CFWL_NoteDriver* pNoteDriver = pIWidget->GetOwnerApp()->GetNoteDriver(); |
532 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); | 528 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); |
533 | 529 |
534 m_pOldDelegate = m_pNormalWidget->GetDelegate(); | 530 m_pOldDelegate = m_pNormalWidget->GetDelegate(); |
(...skipping 30 matching lines...) Expand all Loading... |
565 } | 561 } |
566 dwExtendedStyle |= GetAlignment(); | 562 dwExtendedStyle |= GetAlignment(); |
567 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); | 563 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); |
568 } | 564 } |
569 CXFA_FFDateTimeEdit::CXFA_FFDateTimeEdit(CXFA_FFPageView* pPageView, | 565 CXFA_FFDateTimeEdit::CXFA_FFDateTimeEdit(CXFA_FFPageView* pPageView, |
570 CXFA_WidgetAcc* pDataAcc) | 566 CXFA_WidgetAcc* pDataAcc) |
571 : CXFA_FFTextEdit(pPageView, pDataAcc) {} | 567 : CXFA_FFTextEdit(pPageView, pDataAcc) {} |
572 | 568 |
573 CXFA_FFDateTimeEdit::~CXFA_FFDateTimeEdit() {} | 569 CXFA_FFDateTimeEdit::~CXFA_FFDateTimeEdit() {} |
574 | 570 |
575 FX_BOOL CXFA_FFDateTimeEdit::GetBBox(CFX_RectF& rtBox, | 571 bool CXFA_FFDateTimeEdit::GetBBox(CFX_RectF& rtBox, |
576 uint32_t dwStatus, | 572 uint32_t dwStatus, |
577 FX_BOOL bDrawFocus) { | 573 bool bDrawFocus) { |
578 if (bDrawFocus) | 574 if (bDrawFocus) |
579 return FALSE; | 575 return false; |
580 return CXFA_FFWidget::GetBBox(rtBox, dwStatus); | 576 return CXFA_FFWidget::GetBBox(rtBox, dwStatus); |
581 } | 577 } |
582 | 578 |
583 FX_BOOL CXFA_FFDateTimeEdit::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { | 579 bool CXFA_FFDateTimeEdit::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { |
584 if (!m_pNormalWidget) { | 580 if (!m_pNormalWidget) { |
585 return FALSE; | 581 return false; |
586 } | 582 } |
587 CFX_RectF rtWidget; | 583 CFX_RectF rtWidget; |
588 ((CFWL_DateTimePicker*)m_pNormalWidget)->GetBBox(rtWidget); | 584 ((CFWL_DateTimePicker*)m_pNormalWidget)->GetBBox(rtWidget); |
589 if (rtWidget.Contains(fx, fy)) { | 585 if (rtWidget.Contains(fx, fy)) { |
590 return TRUE; | 586 return true; |
591 } | 587 } |
592 return FALSE; | 588 return false; |
593 } | 589 } |
594 FX_BOOL CXFA_FFDateTimeEdit::LoadWidget() { | 590 bool CXFA_FFDateTimeEdit::LoadWidget() { |
595 CFWL_DateTimePicker* pWidget = new CFWL_DateTimePicker(GetFWLApp()); | 591 CFWL_DateTimePicker* pWidget = new CFWL_DateTimePicker(GetFWLApp()); |
596 pWidget->Initialize(); | 592 pWidget->Initialize(); |
597 m_pNormalWidget = pWidget; | 593 m_pNormalWidget = pWidget; |
598 m_pNormalWidget->SetLayoutItem(this); | 594 m_pNormalWidget->SetLayoutItem(this); |
599 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); | 595 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); |
600 CFWL_NoteDriver* pNoteDriver = pIWidget->GetOwnerApp()->GetNoteDriver(); | 596 CFWL_NoteDriver* pNoteDriver = pIWidget->GetOwnerApp()->GetNoteDriver(); |
601 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); | 597 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); |
602 | 598 |
603 m_pOldDelegate = m_pNormalWidget->GetDelegate(); | 599 m_pOldDelegate = m_pNormalWidget->GetDelegate(); |
604 m_pNormalWidget->SetDelegate(this); | 600 m_pNormalWidget->SetDelegate(this); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 case XFA_ATTRIBUTEENUM_Bottom: | 676 case XFA_ATTRIBUTEENUM_Bottom: |
681 dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVFar; | 677 dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVFar; |
682 break; | 678 break; |
683 default: | 679 default: |
684 dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVNear; | 680 dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVNear; |
685 break; | 681 break; |
686 } | 682 } |
687 } | 683 } |
688 return dwExtendedStyle; | 684 return dwExtendedStyle; |
689 } | 685 } |
690 FX_BOOL CXFA_FFDateTimeEdit::CommitData() { | 686 bool CXFA_FFDateTimeEdit::CommitData() { |
691 CFX_WideString wsText; | 687 CFX_WideString wsText; |
692 ((CFWL_DateTimePicker*)m_pNormalWidget)->GetEditText(wsText); | 688 ((CFWL_DateTimePicker*)m_pNormalWidget)->GetEditText(wsText); |
693 if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) { | 689 if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) { |
694 m_pDataAcc->UpdateUIDisplay(this); | 690 m_pDataAcc->UpdateUIDisplay(this); |
695 return TRUE; | 691 return true; |
696 } | 692 } |
697 return FALSE; | 693 return false; |
698 } | 694 } |
699 FX_BOOL CXFA_FFDateTimeEdit::UpdateFWLData() { | 695 bool CXFA_FFDateTimeEdit::UpdateFWLData() { |
700 if (!m_pNormalWidget) { | 696 if (!m_pNormalWidget) { |
701 return FALSE; | 697 return false; |
702 } | 698 } |
703 XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; | 699 XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; |
704 if (IsFocused()) { | 700 if (IsFocused()) { |
705 eType = XFA_VALUEPICTURE_Edit; | 701 eType = XFA_VALUEPICTURE_Edit; |
706 } | 702 } |
707 CFX_WideString wsText; | 703 CFX_WideString wsText; |
708 m_pDataAcc->GetValue(wsText, eType); | 704 m_pDataAcc->GetValue(wsText, eType); |
709 ((CFWL_DateTimePicker*)m_pNormalWidget)->SetEditText(wsText); | 705 ((CFWL_DateTimePicker*)m_pNormalWidget)->SetEditText(wsText); |
710 if (IsFocused() && !wsText.IsEmpty()) { | 706 if (IsFocused() && !wsText.IsEmpty()) { |
711 CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc); | 707 CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc); |
712 CFX_Unitime date = lcValue.GetDate(); | 708 CFX_Unitime date = lcValue.GetDate(); |
713 if (lcValue.IsValid()) { | 709 if (lcValue.IsValid()) { |
714 if ((FX_UNITIME)date != 0) { | 710 if ((FX_UNITIME)date != 0) { |
715 ((CFWL_DateTimePicker*)m_pNormalWidget) | 711 ((CFWL_DateTimePicker*)m_pNormalWidget) |
716 ->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); | 712 ->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); |
717 } | 713 } |
718 } | 714 } |
719 } | 715 } |
720 m_pNormalWidget->Update(); | 716 m_pNormalWidget->Update(); |
721 return TRUE; | 717 return true; |
722 } | 718 } |
723 FX_BOOL CXFA_FFDateTimeEdit::IsDataChanged() { | 719 bool CXFA_FFDateTimeEdit::IsDataChanged() { |
724 if (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) { | 720 if (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) { |
725 return TRUE; | 721 return true; |
726 } | 722 } |
727 CFX_WideString wsText; | 723 CFX_WideString wsText; |
728 ((CFWL_DateTimePicker*)m_pNormalWidget)->GetEditText(wsText); | 724 ((CFWL_DateTimePicker*)m_pNormalWidget)->GetEditText(wsText); |
729 CFX_WideString wsOldValue; | 725 CFX_WideString wsOldValue; |
730 m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Edit); | 726 m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Edit); |
731 return wsOldValue != wsText; | 727 return wsOldValue != wsText; |
732 } | 728 } |
733 FX_BOOL CXFA_FFDateTimeEdit::CanUndo() { | 729 bool CXFA_FFDateTimeEdit::CanUndo() { |
734 return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanUndo(); | 730 return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanUndo(); |
735 } | 731 } |
736 FX_BOOL CXFA_FFDateTimeEdit::CanRedo() { | 732 bool CXFA_FFDateTimeEdit::CanRedo() { |
737 return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanRedo(); | 733 return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanRedo(); |
738 } | 734 } |
739 FX_BOOL CXFA_FFDateTimeEdit::Undo() { | 735 bool CXFA_FFDateTimeEdit::Undo() { |
740 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Undo(); | 736 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Undo(); |
741 } | 737 } |
742 FX_BOOL CXFA_FFDateTimeEdit::Redo() { | 738 bool CXFA_FFDateTimeEdit::Redo() { |
743 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Redo(); | 739 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Redo(); |
744 } | 740 } |
745 FX_BOOL CXFA_FFDateTimeEdit::CanCopy() { | 741 bool CXFA_FFDateTimeEdit::CanCopy() { |
746 return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanCopy(); | 742 return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanCopy(); |
747 } | 743 } |
748 FX_BOOL CXFA_FFDateTimeEdit::CanCut() { | 744 bool CXFA_FFDateTimeEdit::CanCut() { |
749 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { | 745 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { |
750 return FALSE; | 746 return false; |
751 } | 747 } |
752 return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanCut(); | 748 return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanCut(); |
753 } | 749 } |
754 FX_BOOL CXFA_FFDateTimeEdit::CanPaste() { | 750 bool CXFA_FFDateTimeEdit::CanPaste() { |
755 return m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open; | 751 return m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open; |
756 } | 752 } |
757 FX_BOOL CXFA_FFDateTimeEdit::CanSelectAll() { | 753 bool CXFA_FFDateTimeEdit::CanSelectAll() { |
758 return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanSelectAll(); | 754 return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanSelectAll(); |
759 } | 755 } |
760 FX_BOOL CXFA_FFDateTimeEdit::Copy(CFX_WideString& wsCopy) { | 756 bool CXFA_FFDateTimeEdit::Copy(CFX_WideString& wsCopy) { |
761 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Copy(wsCopy); | 757 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Copy(wsCopy); |
762 } | 758 } |
763 FX_BOOL CXFA_FFDateTimeEdit::Cut(CFX_WideString& wsCut) { | 759 bool CXFA_FFDateTimeEdit::Cut(CFX_WideString& wsCut) { |
764 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Cut(wsCut); | 760 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Cut(wsCut); |
765 } | 761 } |
766 FX_BOOL CXFA_FFDateTimeEdit::Paste(const CFX_WideString& wsPaste) { | 762 bool CXFA_FFDateTimeEdit::Paste(const CFX_WideString& wsPaste) { |
767 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Paste(wsPaste); | 763 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Paste(wsPaste); |
768 } | 764 } |
769 FX_BOOL CXFA_FFDateTimeEdit::SelectAll() { | 765 bool CXFA_FFDateTimeEdit::SelectAll() { |
770 return ((CFWL_DateTimePicker*)m_pNormalWidget)->SelectAll(); | 766 return ((CFWL_DateTimePicker*)m_pNormalWidget)->SelectAll(); |
771 } | 767 } |
772 FX_BOOL CXFA_FFDateTimeEdit::Delete() { | 768 bool CXFA_FFDateTimeEdit::Delete() { |
773 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Delete(); | 769 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Delete(); |
774 } | 770 } |
775 FX_BOOL CXFA_FFDateTimeEdit::DeSelect() { | 771 bool CXFA_FFDateTimeEdit::DeSelect() { |
776 return ((CFWL_DateTimePicker*)m_pNormalWidget)->DeSelect(); | 772 return ((CFWL_DateTimePicker*)m_pNormalWidget)->DeSelect(); |
777 } | 773 } |
778 void CXFA_FFDateTimeEdit::OnSelectChanged(IFWL_Widget* pWidget, | 774 void CXFA_FFDateTimeEdit::OnSelectChanged(IFWL_Widget* pWidget, |
779 int32_t iYear, | 775 int32_t iYear, |
780 int32_t iMonth, | 776 int32_t iMonth, |
781 int32_t iDay) { | 777 int32_t iDay) { |
782 CFX_WideString wsPicture; | 778 CFX_WideString wsPicture; |
783 m_pDataAcc->GetPictureContent(wsPicture, XFA_VALUEPICTURE_Edit); | 779 m_pDataAcc->GetPictureContent(wsPicture, XFA_VALUEPICTURE_Edit); |
784 CXFA_LocaleValue date(XFA_VT_DATE, GetDoc()->GetXFADoc()->GetLocalMgr()); | 780 CXFA_LocaleValue date(XFA_VT_DATE, GetDoc()->GetXFADoc()->GetLocalMgr()); |
785 CFX_Unitime dt; | 781 CFX_Unitime dt; |
(...skipping 15 matching lines...) Expand all Loading... |
801 | 797 |
802 void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { | 798 void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { |
803 if (pEvent->GetClassID() == CFWL_EventType::SelectChanged) { | 799 if (pEvent->GetClassID() == CFWL_EventType::SelectChanged) { |
804 CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent; | 800 CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent; |
805 OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth, | 801 OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth, |
806 event->iDay); | 802 event->iDay); |
807 return; | 803 return; |
808 } | 804 } |
809 CXFA_FFTextEdit::OnProcessEvent(pEvent); | 805 CXFA_FFTextEdit::OnProcessEvent(pEvent); |
810 } | 806 } |
OLD | NEW |