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 "fpdfsdk/pdfwindow/PWL_ComboBox.h" | 7 #include "fpdfsdk/pdfwindow/PWL_ComboBox.h" |
8 | 8 |
9 #include "core/fxge/cfx_pathdata.h" | 9 #include "core/fxge/cfx_pathdata.h" |
10 #include "core/fxge/cfx_renderdevice.h" | 10 #include "core/fxge/cfx_renderdevice.h" |
11 #include "fpdfsdk/fxedit/fxet_list.h" | 11 #include "fpdfsdk/fxedit/fxet_list.h" |
12 #include "fpdfsdk/pdfwindow/PWL_Edit.h" | 12 #include "fpdfsdk/pdfwindow/PWL_Edit.h" |
13 #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" | 13 #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" |
14 #include "fpdfsdk/pdfwindow/PWL_ListBox.h" | 14 #include "fpdfsdk/pdfwindow/PWL_ListBox.h" |
15 #include "fpdfsdk/pdfwindow/PWL_Utils.h" | 15 #include "fpdfsdk/pdfwindow/PWL_Utils.h" |
16 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" | 16 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" |
17 #include "public/fpdf_fwlevent.h" | 17 #include "public/fpdf_fwlevent.h" |
18 | 18 |
19 #define PWLCB_DEFAULTFONTSIZE 12.0f | 19 #define PWLCB_DEFAULTFONTSIZE 12.0f |
20 | 20 |
21 FX_BOOL CPWL_CBListBox::OnLButtonUp(const CFX_FloatPoint& point, | 21 bool CPWL_CBListBox::OnLButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) { |
22 uint32_t nFlag) { | |
23 CPWL_Wnd::OnLButtonUp(point, nFlag); | 22 CPWL_Wnd::OnLButtonUp(point, nFlag); |
24 | 23 |
25 if (!m_bMouseDown) | 24 if (!m_bMouseDown) |
26 return TRUE; | 25 return true; |
27 | 26 |
28 ReleaseCapture(); | 27 ReleaseCapture(); |
29 m_bMouseDown = FALSE; | 28 m_bMouseDown = false; |
30 | 29 |
31 if (!ClientHitTest(point)) | 30 if (!ClientHitTest(point)) |
32 return TRUE; | 31 return true; |
33 if (CPWL_Wnd* pParent = GetParentWindow()) | 32 if (CPWL_Wnd* pParent = GetParentWindow()) |
34 pParent->OnNotify(this, PNM_LBUTTONUP, 0, PWL_MAKEDWORD(point.x, point.y)); | 33 pParent->OnNotify(this, PNM_LBUTTONUP, 0, PWL_MAKEDWORD(point.x, point.y)); |
35 | 34 |
36 FX_BOOL bExit = FALSE; | 35 bool bExit = false; |
37 OnNotifySelChanged(FALSE, bExit, nFlag); | 36 OnNotifySelChanged(false, bExit, nFlag); |
38 | 37 |
39 return !bExit; | 38 return !bExit; |
40 } | 39 } |
41 | 40 |
42 FX_BOOL CPWL_CBListBox::OnKeyDownWithExit(uint16_t nChar, | 41 bool CPWL_CBListBox::OnKeyDownWithExit(uint16_t nChar, |
43 FX_BOOL& bExit, | 42 bool& bExit, |
44 uint32_t nFlag) { | 43 uint32_t nFlag) { |
45 switch (nChar) { | 44 switch (nChar) { |
46 case FWL_VKEY_Up: | 45 case FWL_VKEY_Up: |
47 case FWL_VKEY_Down: | 46 case FWL_VKEY_Down: |
48 case FWL_VKEY_Home: | 47 case FWL_VKEY_Home: |
49 case FWL_VKEY_Left: | 48 case FWL_VKEY_Left: |
50 case FWL_VKEY_End: | 49 case FWL_VKEY_End: |
51 case FWL_VKEY_Right: | 50 case FWL_VKEY_Right: |
52 break; | 51 break; |
53 default: | 52 default: |
54 return FALSE; | 53 return false; |
55 } | 54 } |
56 | 55 |
57 switch (nChar) { | 56 switch (nChar) { |
58 case FWL_VKEY_Up: | 57 case FWL_VKEY_Up: |
59 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 58 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
60 break; | 59 break; |
61 case FWL_VKEY_Down: | 60 case FWL_VKEY_Down: |
62 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 61 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
63 break; | 62 break; |
64 case FWL_VKEY_Home: | 63 case FWL_VKEY_Home: |
65 m_pList->OnVK_HOME(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 64 m_pList->OnVK_HOME(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
66 break; | 65 break; |
67 case FWL_VKEY_Left: | 66 case FWL_VKEY_Left: |
68 m_pList->OnVK_LEFT(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 67 m_pList->OnVK_LEFT(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
69 break; | 68 break; |
70 case FWL_VKEY_End: | 69 case FWL_VKEY_End: |
71 m_pList->OnVK_END(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 70 m_pList->OnVK_END(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
72 break; | 71 break; |
73 case FWL_VKEY_Right: | 72 case FWL_VKEY_Right: |
74 m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 73 m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
75 break; | 74 break; |
76 case FWL_VKEY_Delete: | 75 case FWL_VKEY_Delete: |
77 break; | 76 break; |
78 } | 77 } |
79 | 78 |
80 OnNotifySelChanged(TRUE, bExit, nFlag); | 79 OnNotifySelChanged(true, bExit, nFlag); |
81 | 80 |
82 return TRUE; | 81 return true; |
83 } | 82 } |
84 | 83 |
85 FX_BOOL CPWL_CBListBox::OnCharWithExit(uint16_t nChar, | 84 bool CPWL_CBListBox::OnCharWithExit(uint16_t nChar, |
86 FX_BOOL& bExit, | 85 bool& bExit, |
87 uint32_t nFlag) { | 86 uint32_t nFlag) { |
88 if (!m_pList->OnChar(nChar, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag))) | 87 if (!m_pList->OnChar(nChar, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag))) |
89 return FALSE; | 88 return false; |
90 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow()) | 89 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow()) |
91 pComboBox->SetSelectText(); | 90 pComboBox->SetSelectText(); |
92 | 91 |
93 OnNotifySelChanged(TRUE, bExit, nFlag); | 92 OnNotifySelChanged(true, bExit, nFlag); |
94 | 93 |
95 return TRUE; | 94 return true; |
96 } | 95 } |
97 | 96 |
98 void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { | 97 void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
99 CPWL_Wnd::GetThisAppearanceStream(sAppStream); | 98 CPWL_Wnd::GetThisAppearanceStream(sAppStream); |
100 | 99 |
101 CFX_FloatRect rectWnd = CPWL_Wnd::GetWindowRect(); | 100 CFX_FloatRect rectWnd = CPWL_Wnd::GetWindowRect(); |
102 | 101 |
103 if (IsVisible() && !rectWnd.IsEmpty()) { | 102 if (IsVisible() && !rectWnd.IsEmpty()) { |
104 CFX_ByteTextBuf sButton; | 103 CFX_ByteTextBuf sButton; |
105 | 104 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO); | 155 path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO); |
157 | 156 |
158 pDevice->DrawPath(&path, pUser2Device, nullptr, | 157 pDevice->DrawPath(&path, pUser2Device, nullptr, |
159 CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_BLACKCOLOR, | 158 CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_BLACKCOLOR, |
160 GetTransparency()), | 159 GetTransparency()), |
161 0, FXFILL_ALTERNATE); | 160 0, FXFILL_ALTERNATE); |
162 } | 161 } |
163 } | 162 } |
164 } | 163 } |
165 | 164 |
166 FX_BOOL CPWL_CBButton::OnLButtonDown(const CFX_FloatPoint& point, | 165 bool CPWL_CBButton::OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) { |
167 uint32_t nFlag) { | |
168 CPWL_Wnd::OnLButtonDown(point, nFlag); | 166 CPWL_Wnd::OnLButtonDown(point, nFlag); |
169 | 167 |
170 SetCapture(); | 168 SetCapture(); |
171 | 169 |
172 if (CPWL_Wnd* pParent = GetParentWindow()) { | 170 if (CPWL_Wnd* pParent = GetParentWindow()) { |
173 pParent->OnNotify(this, PNM_LBUTTONDOWN, 0, | 171 pParent->OnNotify(this, PNM_LBUTTONDOWN, 0, |
174 PWL_MAKEDWORD(point.x, point.y)); | 172 PWL_MAKEDWORD(point.x, point.y)); |
175 } | 173 } |
176 | 174 |
177 return TRUE; | 175 return true; |
178 } | 176 } |
179 | 177 |
180 FX_BOOL CPWL_CBButton::OnLButtonUp(const CFX_FloatPoint& point, | 178 bool CPWL_CBButton::OnLButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) { |
181 uint32_t nFlag) { | |
182 CPWL_Wnd::OnLButtonUp(point, nFlag); | 179 CPWL_Wnd::OnLButtonUp(point, nFlag); |
183 | 180 |
184 ReleaseCapture(); | 181 ReleaseCapture(); |
185 | 182 |
186 return TRUE; | 183 return true; |
187 } | 184 } |
188 | 185 |
189 CPWL_ComboBox::CPWL_ComboBox() | 186 CPWL_ComboBox::CPWL_ComboBox() |
190 : m_pEdit(nullptr), | 187 : m_pEdit(nullptr), |
191 m_pButton(nullptr), | 188 m_pButton(nullptr), |
192 m_pList(nullptr), | 189 m_pList(nullptr), |
193 m_bPopup(FALSE), | 190 m_bPopup(false), |
194 m_nPopupWhere(0), | 191 m_nPopupWhere(0), |
195 m_nSelectItem(-1), | 192 m_nSelectItem(-1), |
196 m_pFillerNotify(nullptr) {} | 193 m_pFillerNotify(nullptr) {} |
197 | 194 |
198 CFX_ByteString CPWL_ComboBox::GetClassName() const { | 195 CFX_ByteString CPWL_ComboBox::GetClassName() const { |
199 return "CPWL_ComboBox"; | 196 return "CPWL_ComboBox"; |
200 } | 197 } |
201 | 198 |
202 void CPWL_ComboBox::OnCreate(PWL_CREATEPARAM& cp) { | 199 void CPWL_ComboBox::OnCreate(PWL_CREATEPARAM& cp) { |
203 cp.dwFlags &= ~PWS_HSCROLL; | 200 cp.dwFlags &= ~PWS_HSCROLL; |
204 cp.dwFlags &= ~PWS_VSCROLL; | 201 cp.dwFlags &= ~PWS_VSCROLL; |
205 } | 202 } |
206 | 203 |
207 void CPWL_ComboBox::SetFocus() { | 204 void CPWL_ComboBox::SetFocus() { |
208 if (m_pEdit) | 205 if (m_pEdit) |
209 m_pEdit->SetFocus(); | 206 m_pEdit->SetFocus(); |
210 } | 207 } |
211 | 208 |
212 void CPWL_ComboBox::KillFocus() { | 209 void CPWL_ComboBox::KillFocus() { |
213 SetPopup(FALSE); | 210 SetPopup(false); |
214 CPWL_Wnd::KillFocus(); | 211 CPWL_Wnd::KillFocus(); |
215 } | 212 } |
216 | 213 |
217 CFX_WideString CPWL_ComboBox::GetText() const { | 214 CFX_WideString CPWL_ComboBox::GetText() const { |
218 if (m_pEdit) { | 215 if (m_pEdit) { |
219 return m_pEdit->GetText(); | 216 return m_pEdit->GetText(); |
220 } | 217 } |
221 return CFX_WideString(); | 218 return CFX_WideString(); |
222 } | 219 } |
223 | 220 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 rcEdit.right = rcEdit.left; | 384 rcEdit.right = rcEdit.left; |
388 | 385 |
389 rcEdit.top = rcEdit.bottom + fOldClientHeight; | 386 rcEdit.top = rcEdit.bottom + fOldClientHeight; |
390 | 387 |
391 rcList.bottom += fOldWindowHeight; | 388 rcList.bottom += fOldWindowHeight; |
392 | 389 |
393 break; | 390 break; |
394 } | 391 } |
395 | 392 |
396 if (m_pButton) | 393 if (m_pButton) |
397 m_pButton->Move(rcButton, TRUE, FALSE); | 394 m_pButton->Move(rcButton, true, false); |
398 | 395 |
399 if (m_pEdit) | 396 if (m_pEdit) |
400 m_pEdit->Move(rcEdit, TRUE, FALSE); | 397 m_pEdit->Move(rcEdit, true, false); |
401 | 398 |
402 if (m_pList) { | 399 if (m_pList) { |
403 m_pList->SetVisible(TRUE); | 400 m_pList->SetVisible(true); |
404 m_pList->Move(rcList, TRUE, FALSE); | 401 m_pList->Move(rcList, true, false); |
405 m_pList->ScrollToListItem(m_nSelectItem); | 402 m_pList->ScrollToListItem(m_nSelectItem); |
406 } | 403 } |
407 } else { | 404 } else { |
408 CFX_FloatRect rcButton = rcClient; | 405 CFX_FloatRect rcButton = rcClient; |
409 | 406 |
410 rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH; | 407 rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH; |
411 | 408 |
412 if (rcButton.left < rcClient.left) | 409 if (rcButton.left < rcClient.left) |
413 rcButton.left = rcClient.left; | 410 rcButton.left = rcClient.left; |
414 | 411 |
415 if (m_pButton) | 412 if (m_pButton) |
416 m_pButton->Move(rcButton, TRUE, FALSE); | 413 m_pButton->Move(rcButton, true, false); |
417 | 414 |
418 CFX_FloatRect rcEdit = rcClient; | 415 CFX_FloatRect rcEdit = rcClient; |
419 rcEdit.right = rcButton.left - 1.0f; | 416 rcEdit.right = rcButton.left - 1.0f; |
420 | 417 |
421 if (rcEdit.left < rcClient.left) | 418 if (rcEdit.left < rcClient.left) |
422 rcEdit.left = rcClient.left; | 419 rcEdit.left = rcClient.left; |
423 | 420 |
424 if (rcEdit.right < rcEdit.left) | 421 if (rcEdit.right < rcEdit.left) |
425 rcEdit.right = rcEdit.left; | 422 rcEdit.right = rcEdit.left; |
426 | 423 |
427 if (m_pEdit) | 424 if (m_pEdit) |
428 m_pEdit->Move(rcEdit, TRUE, FALSE); | 425 m_pEdit->Move(rcEdit, true, false); |
429 | 426 |
430 if (m_pList) | 427 if (m_pList) |
431 m_pList->SetVisible(FALSE); | 428 m_pList->SetVisible(false); |
432 } | 429 } |
433 } | 430 } |
434 | 431 |
435 void CPWL_ComboBox::SelectAll() { | 432 void CPWL_ComboBox::SelectAll() { |
436 if (m_pEdit && HasFlag(PCBS_ALLOWCUSTOMTEXT)) | 433 if (m_pEdit && HasFlag(PCBS_ALLOWCUSTOMTEXT)) |
437 m_pEdit->SelectAll(); | 434 m_pEdit->SelectAll(); |
438 } | 435 } |
439 | 436 |
440 CFX_FloatRect CPWL_ComboBox::GetFocusRect() const { | 437 CFX_FloatRect CPWL_ComboBox::GetFocusRect() const { |
441 return CFX_FloatRect(); | 438 return CFX_FloatRect(); |
442 } | 439 } |
443 | 440 |
444 void CPWL_ComboBox::SetPopup(FX_BOOL bPopup) { | 441 void CPWL_ComboBox::SetPopup(bool bPopup) { |
445 if (!m_pList) | 442 if (!m_pList) |
446 return; | 443 return; |
447 if (bPopup == m_bPopup) | 444 if (bPopup == m_bPopup) |
448 return; | 445 return; |
449 FX_FLOAT fListHeight = m_pList->GetContentRect().Height(); | 446 FX_FLOAT fListHeight = m_pList->GetContentRect().Height(); |
450 if (!IsFloatBigger(fListHeight, 0.0f)) | 447 if (!IsFloatBigger(fListHeight, 0.0f)) |
451 return; | 448 return; |
452 | 449 |
453 if (bPopup) { | 450 if (bPopup) { |
454 if (m_pFillerNotify) { | 451 if (m_pFillerNotify) { |
455 #ifdef PDF_ENABLE_XFA | 452 #ifdef PDF_ENABLE_XFA |
456 FX_BOOL bExit = FALSE; | 453 bool bExit = false; |
457 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, 0); | 454 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, 0); |
458 if (bExit) | 455 if (bExit) |
459 return; | 456 return; |
460 #endif // PDF_ENABLE_XFA | 457 #endif // PDF_ENABLE_XFA |
461 int32_t nWhere = 0; | 458 int32_t nWhere = 0; |
462 FX_FLOAT fPopupRet = 0.0f; | 459 FX_FLOAT fPopupRet = 0.0f; |
463 FX_FLOAT fPopupMin = 0.0f; | 460 FX_FLOAT fPopupMin = 0.0f; |
464 if (m_pList->GetCount() > 3) | 461 if (m_pList->GetCount() > 3) |
465 fPopupMin = | 462 fPopupMin = |
466 m_pList->GetFirstHeight() * 3 + m_pList->GetBorderWidth() * 2; | 463 m_pList->GetFirstHeight() * 3 + m_pList->GetBorderWidth() * 2; |
(...skipping 10 matching lines...) Expand all Loading... |
477 default: | 474 default: |
478 case 0: | 475 case 0: |
479 rcWindow.bottom -= fPopupRet; | 476 rcWindow.bottom -= fPopupRet; |
480 break; | 477 break; |
481 case 1: | 478 case 1: |
482 rcWindow.top += fPopupRet; | 479 rcWindow.top += fPopupRet; |
483 break; | 480 break; |
484 } | 481 } |
485 | 482 |
486 m_nPopupWhere = nWhere; | 483 m_nPopupWhere = nWhere; |
487 Move(rcWindow, TRUE, TRUE); | 484 Move(rcWindow, true, true); |
488 #ifdef PDF_ENABLE_XFA | 485 #ifdef PDF_ENABLE_XFA |
489 bExit = FALSE; | 486 bExit = false; |
490 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, 0); | 487 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, 0); |
491 if (bExit) | 488 if (bExit) |
492 return; | 489 return; |
493 #endif // PDF_ENABLE_XFA | 490 #endif // PDF_ENABLE_XFA |
494 } | 491 } |
495 } | 492 } |
496 } else { | 493 } else { |
497 m_bPopup = bPopup; | 494 m_bPopup = bPopup; |
498 Move(m_rcOldWindow, TRUE, TRUE); | 495 Move(m_rcOldWindow, true, true); |
499 } | 496 } |
500 } | 497 } |
501 | 498 |
502 FX_BOOL CPWL_ComboBox::OnKeyDown(uint16_t nChar, uint32_t nFlag) { | 499 bool CPWL_ComboBox::OnKeyDown(uint16_t nChar, uint32_t nFlag) { |
503 if (!m_pList) | 500 if (!m_pList) |
504 return FALSE; | 501 return false; |
505 if (!m_pEdit) | 502 if (!m_pEdit) |
506 return FALSE; | 503 return false; |
507 | 504 |
508 m_nSelectItem = -1; | 505 m_nSelectItem = -1; |
509 | 506 |
510 switch (nChar) { | 507 switch (nChar) { |
511 case FWL_VKEY_Up: | 508 case FWL_VKEY_Up: |
512 if (m_pList->GetCurSel() > 0) { | 509 if (m_pList->GetCurSel() > 0) { |
513 FX_BOOL bExit = FALSE; | 510 bool bExit = false; |
514 #ifdef PDF_ENABLE_XFA | 511 #ifdef PDF_ENABLE_XFA |
515 if (m_pFillerNotify) { | 512 if (m_pFillerNotify) { |
516 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag); | 513 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag); |
517 if (bExit) | 514 if (bExit) |
518 return FALSE; | 515 return false; |
519 bExit = FALSE; | 516 bExit = false; |
520 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag); | 517 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag); |
521 if (bExit) | 518 if (bExit) |
522 return FALSE; | 519 return false; |
523 } | 520 } |
524 #endif // PDF_ENABLE_XFA | 521 #endif // PDF_ENABLE_XFA |
525 if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) { | 522 if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) { |
526 if (bExit) | 523 if (bExit) |
527 return FALSE; | 524 return false; |
528 SetSelectText(); | 525 SetSelectText(); |
529 } | 526 } |
530 } | 527 } |
531 return TRUE; | 528 return true; |
532 case FWL_VKEY_Down: | 529 case FWL_VKEY_Down: |
533 if (m_pList->GetCurSel() < m_pList->GetCount() - 1) { | 530 if (m_pList->GetCurSel() < m_pList->GetCount() - 1) { |
534 FX_BOOL bExit = FALSE; | 531 bool bExit = false; |
535 #ifdef PDF_ENABLE_XFA | 532 #ifdef PDF_ENABLE_XFA |
536 if (m_pFillerNotify) { | 533 if (m_pFillerNotify) { |
537 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag); | 534 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag); |
538 if (bExit) | 535 if (bExit) |
539 return FALSE; | 536 return false; |
540 bExit = FALSE; | 537 bExit = false; |
541 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag); | 538 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag); |
542 if (bExit) | 539 if (bExit) |
543 return FALSE; | 540 return false; |
544 } | 541 } |
545 #endif // PDF_ENABLE_XFA | 542 #endif // PDF_ENABLE_XFA |
546 if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) { | 543 if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) { |
547 if (bExit) | 544 if (bExit) |
548 return FALSE; | 545 return false; |
549 SetSelectText(); | 546 SetSelectText(); |
550 } | 547 } |
551 } | 548 } |
552 return TRUE; | 549 return true; |
553 } | 550 } |
554 | 551 |
555 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) | 552 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) |
556 return m_pEdit->OnKeyDown(nChar, nFlag); | 553 return m_pEdit->OnKeyDown(nChar, nFlag); |
557 | 554 |
558 return FALSE; | 555 return false; |
559 } | 556 } |
560 | 557 |
561 FX_BOOL CPWL_ComboBox::OnChar(uint16_t nChar, uint32_t nFlag) { | 558 bool CPWL_ComboBox::OnChar(uint16_t nChar, uint32_t nFlag) { |
562 if (!m_pList) | 559 if (!m_pList) |
563 return FALSE; | 560 return false; |
564 | 561 |
565 if (!m_pEdit) | 562 if (!m_pEdit) |
566 return FALSE; | 563 return false; |
567 | 564 |
568 m_nSelectItem = -1; | 565 m_nSelectItem = -1; |
569 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) | 566 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) |
570 return m_pEdit->OnChar(nChar, nFlag); | 567 return m_pEdit->OnChar(nChar, nFlag); |
571 | 568 |
572 FX_BOOL bExit = FALSE; | 569 bool bExit = false; |
573 #ifdef PDF_ENABLE_XFA | 570 #ifdef PDF_ENABLE_XFA |
574 if (m_pFillerNotify) { | 571 if (m_pFillerNotify) { |
575 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag); | 572 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag); |
576 if (bExit) | 573 if (bExit) |
577 return FALSE; | 574 return false; |
578 | 575 |
579 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag); | 576 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag); |
580 if (bExit) | 577 if (bExit) |
581 return FALSE; | 578 return false; |
582 } | 579 } |
583 #endif // PDF_ENABLE_XFA | 580 #endif // PDF_ENABLE_XFA |
584 return m_pList->OnCharWithExit(nChar, bExit, nFlag) ? bExit : FALSE; | 581 return m_pList->OnCharWithExit(nChar, bExit, nFlag) ? bExit : false; |
585 } | 582 } |
586 | 583 |
587 void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd, | 584 void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd, |
588 uint32_t msg, | 585 uint32_t msg, |
589 intptr_t wParam, | 586 intptr_t wParam, |
590 intptr_t lParam) { | 587 intptr_t lParam) { |
591 switch (msg) { | 588 switch (msg) { |
592 case PNM_LBUTTONDOWN: | 589 case PNM_LBUTTONDOWN: |
593 if (pWnd == m_pButton) { | 590 if (pWnd == m_pButton) { |
594 SetPopup(!m_bPopup); | 591 SetPopup(!m_bPopup); |
595 return; | 592 return; |
596 } | 593 } |
597 break; | 594 break; |
598 case PNM_LBUTTONUP: | 595 case PNM_LBUTTONUP: |
599 if (m_pEdit && m_pList) { | 596 if (m_pEdit && m_pList) { |
600 if (pWnd == m_pList) { | 597 if (pWnd == m_pList) { |
601 SetSelectText(); | 598 SetSelectText(); |
602 SelectAll(); | 599 SelectAll(); |
603 m_pEdit->SetFocus(); | 600 m_pEdit->SetFocus(); |
604 SetPopup(FALSE); | 601 SetPopup(false); |
605 return; | 602 return; |
606 } | 603 } |
607 } | 604 } |
608 } | 605 } |
609 | 606 |
610 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); | 607 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); |
611 } | 608 } |
612 | 609 |
613 FX_BOOL CPWL_ComboBox::IsPopup() const { | 610 bool CPWL_ComboBox::IsPopup() const { |
614 return m_bPopup; | 611 return m_bPopup; |
615 } | 612 } |
616 | 613 |
617 void CPWL_ComboBox::SetSelectText() { | 614 void CPWL_ComboBox::SetSelectText() { |
618 m_pEdit->SelectAll(); | 615 m_pEdit->SelectAll(); |
619 m_pEdit->ReplaceSel(m_pList->GetText()); | 616 m_pEdit->ReplaceSel(m_pList->GetText()); |
620 m_pEdit->SelectAll(); | 617 m_pEdit->SelectAll(); |
621 m_nSelectItem = m_pList->GetCurSel(); | 618 m_nSelectItem = m_pList->GetCurSel(); |
622 } | 619 } |
623 | 620 |
624 void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify) { | 621 void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify) { |
625 m_pFillerNotify = pNotify; | 622 m_pFillerNotify = pNotify; |
626 | 623 |
627 if (m_pEdit) | 624 if (m_pEdit) |
628 m_pEdit->SetFillerNotify(pNotify); | 625 m_pEdit->SetFillerNotify(pNotify); |
629 | 626 |
630 if (m_pList) | 627 if (m_pList) |
631 m_pList->SetFillerNotify(pNotify); | 628 m_pList->SetFillerNotify(pNotify); |
632 } | 629 } |
OLD | NEW |